.htaccess 方式实现网址平滑(301)跳转(伪静态同样实现)
相信许多站长希望做到如下
访问 http://monkeye.cn/thread-2123-1-1.html
变成 http://www.monkeye.cn/thread-2123-1-1.html
访问 http://monkeye.cn/
变成 http://www.monkeye.cn/
-----------------------------
访问 http://cxlcn.com/
变成 http://www.cxlnc.om
访问 http://cxlcn.com/showlog-107.html
变成 http://www.cxlcn.com/showlog-107.html
-----------------------------
访问 http://www.cxlcn.com/bbs/forum-3-1.html
以及 http://cxlcn.com/bbs/forum-3-1.html
以上将变成 http://bbs.udisad.com/forum-3-1.html
实现方法
打开 .htaccess 找到
RewriteEngine on
它的下方添加
RewriteCond %{HTTP_HOST} ^需要被转向的网址$
RewriteRule ^(.*)$ http://转向后的网址/$1 [R=301,L]
注意:如果 xxx.com 与 www.xxx.com 同一个目录时,需要将 xxx.com 转向到 www.xxx.com 时,添加的2条都是必须的。如果当 xxx.com 与 zzz.com 不同目录时,则只需要添加 RewriteRule ^(.*)$ http://转向后的网址/$1 [R=301,L] 即可

2009-05-25 22:35
RewriteEngine on
RewriteCond %{http_host} ^xfsq.net [NC]
RewriteRule ^(.*)$ http://www.xfsq.net/$1 [L,R=301]
应该是这样写吧。
2009-04-27 10:49
很好的东西
比如DW 和 DZ 很多论坛
带www 很没带 有很多问题...