DISCUZ X3实现LINUX 虚拟主机环境下的301+伪静态教程
只适用于DISCUZ X系列,首先登录后台,然后进全局,SEO里设置,记住,设置好伪静态后,记得更新缓存,再去全局里 查看当前的伪静态规则并复制,还有,新手的一个失败原因就是 RewriteBase / 这里.
比如你的DZ在空间的路径是这样的:/domains/www.abc.com/public_html,一开始我的错误就是写成了RewriteBase /domains/www.phpfensi.com/public_html,从而导致404错误!
正确的应该是RewriteBase /,还有就是把.htaccess上传的时候记得需要用二进制,我把.htaccess文件样本放这里吧,代码如下:
- RewriteEngine On
- RewriteCond %{HTTP_HOST} !^www.phpfensi.com$ [NC]
- RewriteRule ^(.*)$ http://www.phpfensi.com/$1 [L,R=301]
- RewriteBase /
- 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\=$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 ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1
- RewriteCond %{QUERY_STRING} ^(.*)$
- RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
- RewriteCond %{QUERY_STRING} ^(.*)$
- RewriteRule ^([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ plugin.php?id=$1:$2&%1