discuz 生成静态html,Discuz论坛静态化设置方法
URL靜態化可以提高搜索引擎抓取,Discuz論壇程序是如何實現URL靜態化的呢?
為給大家提供發布問題、解決問題、分享經驗的平臺,本站現已開啟經驗交流區(基于Discuz論壇程序)。
剛使用Discuz程序搭建交流區的時候碰到了幾個問題,不過通過百度一下均都得以解決。特開啟Discuz欄目為DZ建站者們分享Discuz常見問題及解決方案,希望經驗分享為你所用!
Discuz論壇程序如何開啟URL靜態化?
登錄Discuz后臺,Rewrite設置方法:全局——>SEO設置——>URL 靜態化
discuz論壇URL靜態化
如上圖,勾選需要URL靜態化的頁面,然后點擊右上角的“查看當前的 Rewrite 規則URL 靜態化”鏈接。可以看到Discuz已經為我們生成了Rewrite規則,如下所示:
Apache Web Server(獨立主機用戶)
RewriteEngine?On
RewriteCond?%{QUERY_STRING}?^(.*)$
RewriteRule?^(.*)/topic-(.+)\.html$?$1/portal.php?mod=topic&topic=$2&%1
RewriteCond?%{QUERY_STRING}?^(.*)$
RewriteRule?^(.*)/article-([0-9]+)-([0-9]+)\.html$?$1/portal.php?mod=view&aid=$2&page=$3&%1
RewriteCond?%{QUERY_STRING}?^(.*)$
RewriteRule?^(.*)/forum-(\w+)-([0-9]+)\.html$?$1/forum.php?mod=forumdisplay&fid=$2&page=$3&%1
RewriteCond?%{QUERY_STRING}?^(.*)$
RewriteRule?^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$?$1/forum.php?mod=viewthread&tid=$2&extra=page\%3D$4&page=$3&%1
RewriteCond?%{QUERY_STRING}?^(.*)$
RewriteRule?^(.*)/(fid|tid)-([0-9]+)\.html$?$1/archiver/index.php?action=$2&value=$3&%1
Apache Web Server(虛擬主機用戶)
#?將?RewriteEngine?模式打開
RewriteEngine?On
#?修改以下語句中的?/discuz?為您的論壇目錄地址,如果程序放在根目錄中,請將?/discuz?修改為?/
RewriteBase?/discuz
#?Rewrite?系統規則請勿修改
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?^(fid|tid)-([0-9]+)\.html$?archiver/index.php?action=$1&value=$2&%1
IIS Web Server(獨立主機用戶)
[ISAPI_Rewrite]
#?3600=1hour
CacheClockRate?3600
RepeatLimit?32
#?Protect?httpd.ini?and?httpd.parse.errors?files
#?from?accessing?through?HTTP
RewriteRule?^(.*)/topic-(.+)\.html(\?(.*))*$?$1/portal\.php\?mod=topic&topic=$2&$4
RewriteRule?^(.*)/article-([0-9]+)-([0-9]+)\.html(\?(.*))*$?$1/portal\.php\?mod=view&aid=$2&page=$3&$5
RewriteRule?^(.*)/forum-(\w+)-([0-9]+)\.html(\?(.*))*$?$1/forum\.php\?mod=forumdisplay&fid=$2&page=$3&$5
RewriteRule?^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html(\?(.*))*$?$1/forum\.php\?mod=viewthread&tid=$2&extra=page\%3D$4&page=$3&$6
RewriteRule?^(.*)/(fid|tid)-([0-9]+)\.html(\?(.*))*$?$1/archiver/index\.php\?action=$2&value=$3&$5
IIS7 Web Server(獨立主機用戶)
Zeus Web Server
match?URL?into?$?with?^(.*)/topic-(.+)\.html\?*(.*)$
if?matched?then
set?URL=?$1/portal.php?mod=topic&topic=$2&$3
endif
match?URL?into?$?with?^(.*)/article-([0-9]+)-([0-9]+)\.html\?*(.*)$
if?matched?then
set?URL=?$1/portal.php?mod=view&aid=$2&page=$3&$4
endif
match?URL?into?$?with?^(.*)/forum-(\w+)-([0-9]+)\.html\?*(.*)$
if?matched?then
set?URL=?$1/forum.php?mod=forumdisplay&fid=$2&page=$3&$4
endif
match?URL?into?$?with?^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html\?*(.*)$
if?matched?then
set?URL=?$1/forum.php?mod=viewthread&tid=$2&extra=page\%3D$4&page=$3&$5
endif
match?URL?into?$?with?^(.*)/(fid|tid)-([0-9]+)\.html\?*(.*)$
if?matched?then
set?URL=?$1/archiver/index.php?action=$2&value=$3&$4
endif
Nginx Web Server
rewrite?^([^\.]*)/topic-(.+)\.html$?$1/portal.php?mod=topic&topic=$2?last;
rewrite?^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$?$1/portal.php?mod=view&aid=$2&page=$3?last;
rewrite?^([^\.]*)/forum-(\w+)-([0-9]+)\.html$?$1/forum.php?mod=forumdisplay&fid=$2&page=$3?last;
rewrite?^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$?$1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3?last;
rewrite?^([^\.]*)/(fid|tid)-([0-9]+)\.html$?$1/archiver/index.php?action=$2&value=$3?last;
if?(!-e?$request_filename)?{
return?404;
}
重要說明:
以上規則是根據上圖中勾選的頁面后自動生成的。根據自己的服務器類型選擇對應的規則,比如 久久經驗網 的服務器是Apache,那就不能選IIS Web Server。
如果discuz論壇程序是建立在根目錄,就將對應的Rewrite規則粘貼到.htaccess文件里通過FTP上傳到根目錄;如果discuz論壇程序是在網站里擴展出來的,比如:根目錄/bbs,則將此.htaccess文件存放在bbs目錄下。久久經驗網的經驗交流區采取的就是這種方式。
以上規則都設置好后重新更新緩存,刷新前臺界面discuz論壇的板塊鏈接就變成靜態的了,如:本站經驗交流區的Web技術分區下的Web前端板塊https://www.exp99.com/bbs/forum-2-1.html。
總結
以上是生活随笔為你收集整理的discuz 生成静态html,Discuz论坛静态化设置方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: html 调用main方法,ipcmai
- 下一篇: html隐藏目录在哪里查找,使用Dirs