欢迎访问服务器技术网-www.fuwuqijishu.com

Discuz程序通用.HTACCESS伪静态文件及设置方法

运维 fuwuqijishu 2年前 (2022-09-04) 100次浏览 0个评论 扫描二维码

一般我们使用DISCUZ程序架构网站的时候肯定会启动伪静态功能,这样对搜索引擎、用户体验也是比较好的。如果我们使用的VPS/主机环境是APACHE的,我们直接在网站根目录放置.htaccess文件,然后文件中放上对应版本的DISCUZ伪静态规则就可以。

这篇文章中,整理到最新版本适合基本所有的DISCUZ程序的伪静态文件。

RewriteEngine On
RewriteBase /discuz

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 ^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

以上文件复制到我们的.htaccess文件中,然后上传到网站根目录。注意修改”RewriteBase /discuz”部分,如果是网站根目录,那就直接”RewriteBase /”,如果在目录文件夹中,对应修改自己的文件夹。

同时,我们需要在管理员后台启动。”全局”-“SEO”设置部分,勾选需要启动伪静态的文件路径,开启Rewrite规则为”是”。这样我们就完成了对discuz的伪静态设置。

喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

Warning: error_log(/www/wwwroot/fuwiqijishu/wp-content/plugins/spider-analyser/#log/log-0215.txt): failed to open stream: No such file or directory in /www/wwwroot/fuwiqijishu/wp-content/plugins/spider-analyser/spider.class.php on line 2900