admin 发表于 2023-1-27 18:37:06

如何设置Xiuno BBS URL-Rewrite(伪静态设定)

如何设置Xiuno BBS URL-Rewrite(伪静态设定)
XiunoBBS 只需要一条规则:将 *.htm* 转发到 index.php?*.htm* 即可。
Xiuno BBS 4.0需要编辑 conf/conf.php1. 编辑 'url_rewrite_on'=>1,2. 清空 tmp 目录

Nginx:打开 nginx 配置文件 /usr/local/nginx/conf/nginx.conf 找到对应的虚拟主机配置处,追加加粗行:
location ~* \.(htm)$ {    rewrite "^(.*)/(.+?).htm(.*?)$" $1/index.php?$2.htm$3 last;}
然后重新启动 nginx: service nginx restart
Apache:
vim /etc/httpd/conf/httpd.conf<Directory d:/xiuno.com>    Options FollowSymLinks ExecCGI Indexes    AllowOverride all    Order deny,allow    Allow from all    Satisfy all</Directory>NameVirtualHost *:80
Apache .htaccess如果Appache 支持 .htaccess,那么可以编辑 .htaccess 文件放置于根目录下:<IfModule mod_rewrite.c>RewriteEngine on
# Apache 2.4RewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^(.*?)([^/]*)$ $1index.php?$2
# Apache other#RewriteRule ^(.*?)([^/]*)\.htm(.*)$ $1/index.php?$2.htm$3 </IfModule>
Apache httpd.conf
如果将规则直接放入 httpd.conf 则需要在前面加 / ,看来 Apache 也反人类:<IfModule mod_rewrite.c>RewriteEngine onRewriteRule ^(.*?)([^/]*)\.htm(.*)$ $1/index.php?$2.htm$3 </IfModule>

SAE环境,根目录建立 config.yaml 文件:appname: axiuno
version: 1
handle:
- rewrite: if ( !is_dir() && !is_file() && path ~ "admin/(.*.htm)" ) goto "admin/index.php?%1"- rewrite: if ( !is_dir() && !is_file() && path ~ "[^/?].htm" ) goto "index.php?%1"


IIS:
1. 下载Rewrite.zip2. 解压到 c:\Rewrite3. 在IIS的Isapi上添加这个筛选器, 筛选器名称Rewrite,可执行文件选择 Rewrite.dll4. 重新启动IIS5. httpd.ini 是配置文件,如果您了解Rewrite 规则,可以直接对其进行编辑,以下为包内设置好的Xiuno BBS的规则:# 3600 = 1 hourCacheClockRate 3600RepeatLimit 32#RewriteRule .*\.(?:gif|jpg|png|css|js|txt|jpeg|swf|flv) $0 #RewriteRule /httpd(?:\.ini|\.parse\.errors) / RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^/admin(.*)\.htm(.*) /admin/index.php?$1.htm$2
RewriteRule ^(.*)\.htm(.*) /index.php?$1.htm$2



另外一种 IIS Rewrite:# 3600 = 1 hourCacheClockRate 3600RepeatLimit 32RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^/admin/(.*)\.htm(.*) /admin/$1.htm$2 RewriteRule ^(.*)\.htm(.*)$ /$1.htm$2

如果要放到目录下,比如 bbs 目录,在 rewrite 规则前面加上目录即可,比如 apache .htaccess:
<IfModule mod_rewrite.c>RewriteEngine onRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^bbs/admin/(.*)\.htm(.*)$ /admin/index.php?$1.htm$2
RewriteRule ^bbs/(.*)\.htm(.*)$ /index.php?$1.htm$2
</IfModule>
页: [1]
查看完整版本: 如何设置Xiuno BBS URL-Rewrite(伪静态设定)