0 0 0

XiunoBBS(修罗论坛)如何设置伪静态(URL-Rewrite) 以及4.0.4版本源码下载

静水流深
7天前 88

XiunoBBS 只需要一条规则:

将 *.htm* 转发到 index.php?*.htm">* 即可。

XIUNOBBS 4.0  需要编辑 conf/conf.php

1. 编辑 "url_rewrite_on"=>1,

2. 清空 tmp 目录 

Nginx:

打开 nginx 配置文件 /usr/local/nginx/conf/nginx.conf 找到对应的虚拟主机配置处,追加加粗行:

  1. location ~* \.(htm)$ {
  2. rewrite "^(.*)/(.+?).htm(.*?)$" $1/index.php?$2.htm$3 last;
  3. }

然后重新启动 nginx: service nginx restart

Apache: 

vim /etc/httpd/conf/httpd.conf

  1. <Directory d:/xiuno.com>
  2. Options FollowSymLinks ExecCGI Indexes
  3. AllowOverride all
  4. Order deny,allow
  5. Allow from all
  6. Satisfy all
  7. </Directory>
  8. NameVirtualHost *:80

Apache .htaccess

如果Appache 支持 .htaccess,那么可以编辑 .htaccess 文件放置于根目录下:

  1. <IfModule mod_rewrite.c>
  2. RewriteEngine on
  3. # Apache 2.4
  4. RewriteCond %{REQUEST_FILENAME} !-d
  5. RewriteCond %{REQUEST_FILENAME} !-f
  6. RewriteRule ^(.*?)([^/]*)$ $1index.php?$2 [QSA,PT,L]
  7. # Apache other
  8. #RewriteRule ^(.*?)([^/]*)\.htm(.*)$ $1/index.php?$2.htm$3 [L]
  9. </IfModule>

Apache httpd.conf

如果将规则直接放入 httpd.conf 则需要在前面加 / ,看来 Apache 也反人类:

  1. <IfModule mod_rewrite.c>
  2. RewriteEngine on
  3. RewriteRule ^(.*?)([^/]*)\.htm(.*)$ $1/index.php?$2.htm$3 [L]
  4. </IfModule>

 SAE环境,根目录建立 config.yaml 文件:

  1. appname: axiuno
  2. version: 1
  3. handle:
  4. - rewrite: if ( !is_dir() && !is_file() && path ~ "admin/(.*.htm)" ) goto "admin/index.php?%1"
  5. - rewrite: if ( !is_dir() && !is_file() && path ~ "[^/?].htm" ) goto "index.php?%1"

IIS: 

1. 下载 Rewrite.zip

2. 解压到 c:\Rewrite

3. 在IIS的Isapi上添加这个筛选器, 筛选器名称Rewrite,可执行文件选择 Rewrite.dll

4. 重新启动IIS

5. httpd.ini 是配置文件,如果您了解Rewrite 规则,可以直接对其进行编辑,以下为包内设置好的XIUNOBBS的规则:

  1. [ISAPI_Rewrite]
  2. # 3600 = 1 hour
  3. CacheClockRate 3600
  4. RepeatLimit 32
  5. #RewriteRule .*\.(?:gif|jpg|png|css|js|txt|jpeg|swf|flv) $0 [I,L]
  6. #RewriteRule /httpd(?:\.ini|\.parse\.errors) / [F,I,O]
  7. RewriteCond %{REQUEST_FILENAME} !-f
  8. RewriteCond %{REQUEST_FILENAME} !-d
  9. RewriteRule ^/admin(.*)\.htm(.*) /admin/index.php?$1.htm$2 [L]
  10. RewriteRule ^(.*)\.htm(.*) /index.php?$1.htm$2 [L]

另外一种 IIS Rewrite:

  1. [ISAPI_Rewrite]
  2. # 3600 = 1 hour
  3. CacheClockRate 3600
  4. RepeatLimit 32
  5. RewriteCond %{REQUEST_FILENAME} !-f
  6. RewriteCond %{REQUEST_FILENAME} !-d
  7. RewriteRule ^/admin/(.*)\.htm(.*) /admin/$1.htm$2 [L]
  8. RewriteRule ^(.*)\.htm(.*)$ /$1.htm$2 [L]

如果要放到目录下,比如 bbs 目录,在 rewrite 规则前面加上目录即可,比如 apache .htaccess:

  1. <IfModule mod_rewrite.c>
  2. RewriteEngine on
  3. RewriteCond %{REQUEST_FILENAME} !-d
  4. RewriteCond %{REQUEST_FILENAME} !-f
  5. RewriteRule ^bbs/admin/(.*)\.htm(.*)$ /admin/index.php?$1.htm$2 [L]
  6. RewriteRule ^bbs/(.*)\.htm(.*)$ /index.php?$1.htm$2 [L]
  7. </IfModule>

IIS 的高版本配置方法:

Xiuno3 IIS7,IIS7.5伪静态规则,懒人版

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <configuration>
  3. <system.webServer>
  4. <rewrite>
  5. <rules>
  6. <rule name="xiuno3">
  7. <match url="^((.*)/)?(.+).htm$" />
  8. <action type="Rewrite" url="{R:1}\index.php?{R:2}.htm" />
  9. </rule>
  10. </rules>
  11. </rewrite>
  12. </system.webServer>
  13. </configuration>

IIS 的高版本配置方法1:http://bbs.xiuno.com/thread-9008.htm

IIS 的高版本配置方法2:http://bbs.xiuno.com/thread-9411.htm

IIS 的详细配置方法请参看:http://my.oschina.net/lyx2012/blog/60198

IIS Rewrite 支持 Apache .htaccess :ISAPI_Rewrite3.zip   

反人类的 IIS REWRITE!!!

Caddy
  1. www.yourdomain.com
  2. # Set this path to your site"s directory.
  3. root * /var/www
  4. file_server
  5. # Or serve a PHP site through php-fpm:
  6. php_fastcgi localhost:9000
SAE
  1. appname: axiuno
  2. version: 1
  3. handle:
  4. - rewrite: if ( !is_dir() && !is_file() && path ~ "admin/(.*.htm)" ) goto "admin/index.php?%1"
  5. - rewrite: if ( !is_dir() && !is_file() && path ~ "[^/?].htm" ) goto "index.php?%1"

XIUNOBBS百度云虚拟主机BCH伪静态加载—url重写" href="thread-165.htm">XIUNOBBS百度云虚拟主机BCH伪静态加载—url重写

 

 

 

xiuno论坛源码:

https://cnwebmasters.com/download/xiunobbs_4.0.4.zip 

 

支持五种语言(简体、繁体、英文、俄语、泰语)。

4.0.4官方版修改兼容php7.3+

在XIUNOBBS原基础上支持php7.3及更高版本

xiunophp/misc.func.php文件大约1034行的http_url_path方法在php8.1下报错解决方法:

源代码:

  1. // 获取 http://xxx.com/path/
  2. function http_url_path() {
  3. $port = _SERVER("SERVER_PORT");
  4. //$portadd = ($port == 80 ? "" : ":".$port);
  5. $host = _SERVER("HTTP_HOST"); // host 里包含 port
  6. $https = strtolower(_SERVER("HTTPS", "off"));
  7. $proto = strtolower(_SERVER("HTTP_X_FORWARDED_PROTO"));
  8. $path = substr($_SERVER["PHP_SELF"], 0, strrpos($_SERVER["PHP_SELF"], "/"));
  9. $http = (($port == 443) || $proto == "https" || ($https && $https != "off")) ? "https" : "http";
  10. return "$http://$host$path/";
  11. }

更改后:

  1. // 获取 http://xxx.com/path/
  2. function http_url_path() {
  3. $port = _SERVER("SERVER_PORT");
  4. //$portadd = ($port == 80 ? "" : ":".$port);
  5. $host = _SERVER("HTTP_HOST"); // host 里包含 port
  6. $https = strtolower(_SERVER("HTTPS", "off"));
  7. $proto = _SERVER("HTTP_X_FORWARDED_PROTO") ? strtolower(_SERVER("HTTP_X_FORWARDED_PROTO")) : ""; //此处加判断
  8. $path = substr($_SERVER["PHP_SELF"], 0, strrpos($_SERVER["PHP_SELF"], "/"));
  9. $http = (($port == 443) || $proto == "https" || ($https && $https != "off")) ? "https" : "http";
  10. return "$http://$host$path/";
  11. }
最新回复 (0)

    暂无评论

请先登录后发表评论!

返回
请先登录后发表评论!