论坛 修改.htaccess 加入如下代码:
- RewriteEngine On
- # 修改以下语句中的 /x 为你的论坛目录地址,如果程序放在根目录中,请将 /x 修改为 /
- RewriteBase /x
- RewriteCond %{QUERY_STRING} ^(.*)$
- RewriteRule ^(forumdisplay|viewthread|redirect|faq).php forum.php?mod=$1&%1
- RewriteCond %{QUERY_STRING} ^(.*)$
- RewriteRule ^(space).php home.php?mod=$1&%1
升级到 Discuz!X 后 保持 UCHOME 原链接可正常访问 rewrite
- RewriteRule ^(.*)/space-(d+)-do-(.+)-(.+)-([0-9]+).html?*(.*)$ $1/home.php?mod=space&uid=$2&do=$3&$4=$5
- RewriteRule ^(.*)/space-mtag.html?*(.*)$ $1/group.php
- RewriteRule ^(.*)/space-event.html?*(.*)$ $1/home.php?mod=space&do=activity
- RewriteRule ^(.*)/space-(.*).html?*(.*)$ $1/home.php?mod=space&do=$2
论坛 Nginx 的写法:
- rewrite ^(.*)/(forumdisplay|viewthread|redirect|faq).php $1/forum.php?mod=$2&$query_string last;
- rewrite ^(.*)/(space).php $1/home.php?mod=$2&$query_string last;
iis6 下规则
- [ISAPI_Rewrite]
- # 3600 = 1 hour
- CacheClockRate 3600
- RepeatLimit 32
- RewriteRule ^(.*)/(forumdisplay|viewthread|redirect|faq).php?(.*) $1/forum.php?mod=$2&$3
- RewriteRule ^(.*)/(space).php?(.*) $1/home.php?mod=$2&$3
iis7 下规则加在 web.config 里面
- <rule name="for_bbs">
- <match url="^(.*)/(forumdisplay|viewthread|redirect|faq).php" />
- <action type="Rewrite" url="{R:1}/forum.php?mod={R:2}&%{QUERY_STRING}" />
- </rule>
- <rule name="for_uchome">
- <match url="^(.*)/(space).php" />
- <action type="Rewrite" url="{R:1}/home.php?mod={R:2}&%{QUERY_STRING}" />
- </rule>
apache 独立主机
- <IfModule mod_rewrite.c>
- RewriteRule ^(.*)/(forumdisplay|viewthread|redirect|faq).php $1/forum.php?mod=$2&%{QUERY_STRING}
- RewriteRule ^(.*)/(space).php $1/home.php?mod=$2&%{QUERY_STRING}
- </IfModule>
对于源程序在 bbs 文件夹, 升级后在根目录了, 保持原链接不失效的方法
- RewriteEngine On
- # 修改以下语句中的 /x 为你的论坛目录地址,如果程序放在根目录中,请将 /x 修改为 /
- RewriteBase /
- RewriteRule ^bbs(.*)$ http://www.violinstudy.net$1 [R]
- RewriteCond %{QUERY_STRING} ^(.*)$
- RewriteRule ^(forumdisplay|viewthread|redirect|faq).php forum.php?mod=$1&%1
- RewriteCond %{QUERY_STRING} ^(.*)$
- RewriteRule ^(space).php home.php?mod=$1&%1
- RewriteCond %{QUERY_STRING} ^(.*)$
- RewriteRule ^topic-(.+).html$ portal.php?mod=topic&topic=$1&%1
- RewriteCond %{QUERY_STRING} ^(.*)$
- RewriteRule ^article-([0-9]+)-([0-9]+).html$ portal.php?mod=view&aid=$1&page=$2&%1
- RewriteCond %{QUERY_STRING} ^(.*)$
- RewriteRule ^forum-(w+)-([0-9]+).html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
- RewriteCond %{QUERY_STRING} ^(.*)$
- RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+).html$ forum.php?mod=viewthread&tid=$1&extra=page%3D$3&page=$2&%1
- RewriteCond %{QUERY_STRING} ^(.*)$
- RewriteRule ^group-([0-9]+)-([0-9]+).html$ forum.php?mod=group&fid=$1&page=$2&%1
- RewriteCond %{QUERY_STRING} ^(.*)$
- RewriteRule ^space-(username|uid)-(.+).html$ home.php?mod=space&$1=$2&%1
- RewriteCond %{QUERY_STRING} ^(.*)$
- RewriteRule ^([a-z]+)-(.+).html$ $1.php?rewrite=$2&%1