新聞中心
Discuz如何根據(jù)服務(wù)器環(huán)境配置對應(yīng)的偽靜態(tài)
我們常常會訪問到用discuz建立的論壇網(wǎng)站,并且基本上所有的論壇網(wǎng)站都設(shè)置了偽靜態(tài)。偽靜態(tài)的設(shè)置教程,無憂主機(jī)小編之前也分享過多次,這里就不重復(fù)了。詳細(xì)教程參考鏈接:DISCUZ 3.0偽靜態(tài)設(shè)置圖文幫助教程。今天無憂主機(jī)小編給大家?guī)淼慕坛?,同樣與discuz偽靜態(tài)的配置有關(guān)。比如無憂主機(jī)的php空間,我們的用戶在設(shè)置discuz偽靜態(tài)的過程中,都是在網(wǎng)站根目錄上傳.htaccess文件,里面添加對應(yīng)php虛擬主機(jī)的規(guī)則,然后在后臺設(shè)置好,就可以了。小編也一度以為,只有是discuz,偽靜態(tài)的設(shè)置方法就是這樣的。最近無憂主機(jī)小編發(fā)現(xiàn),不同的運(yùn)行環(huán)境,規(guī)則也千差萬別。今天小編就給大家介紹一下具體有哪一些類型。 在設(shè)置偽靜態(tài)之前,我們需要確定自己的運(yùn)行環(huán)境。那么如何確認(rèn)呢?其實(shí)discuz有一個自帶檢測環(huán)境的功能。我們只需要登陸網(wǎng)站后臺,首頁——管理中心首頁——系統(tǒng)信息,就可以看到當(dāng)前的服務(wù)器配置和php版本了,如圖所示: 在確認(rèn)了環(huán)境之后,我們就需要根據(jù)環(huán)境來添加對應(yīng)的偽靜態(tài)規(guī)則了。那么閑言少敘,直接把所有的環(huán)境可能以及對應(yīng)的規(guī)則分享給大家。 一、服務(wù)器系統(tǒng)及 PHP:WINNT / PHP v5.X.X 服務(wù)器軟件:Microsoft-IIS/6.0 這種環(huán)境對應(yīng)的是IIS Web Server(獨(dú)立主機(jī)用戶),對應(yīng)的規(guī)則為:
[ISAPI_Rewrite] # 3600 = 1 hour 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 ^(.*)/group-([0-9]+)-([0-9]+)\.html(\?(.*))*$ $1/forum\.php\?mod=group&fid=$2&page=$3&$5 RewriteRule ^(.*)/space-(username|uid)-(.+)\.html(\?(.*))*$ $1/home\.php\?mod=space&$2=$3&$5 RewriteRule ^(.*)/blog-([0-9]+)-([0-9]+)\.html(\?(.*))*$ $1/home\.php\?mod=space&uid=$2&do=blog&id=$3&$5 RewriteRule ^(.*)/(fid|tid)-([0-9]+)\.html(\?(.*))*$ $1/index\.php\?action=$2&value=$3&$5二、服務(wù)器系統(tǒng)及 PHP:WINNT / PHP v5.2.16 服務(wù)器軟件:Microsoft-IIS/7.X 這種環(huán)境對應(yīng)的是IIS7 Web Server(獨(dú)立主機(jī)用戶),對應(yīng)的規(guī)則是:
<rewrite> <rules> <rule name="portal_topic"> <match url="^(.*/)*topic-(.+).html\?*(.*)$" /> <action type="Rewrite" url="{R:1}/portal.php\?mod=topic&topic={R:2}&{R:3}" /> </rule> <rule name="portal_article"> <match url="^(.*/)*article-([0-9]+)-([0-9]+).html\?*(.*)$" /> <action type="Rewrite" url="{R:1}/portal.php\?mod=view&aid={R:2}&page={R:3}&{R:4}" /> </rule> <rule name="forum_forumdisplay"> <match url="^(.*/)*forum-(\w+)-([0-9]+).html\?*(.*)$" /> <action type="Rewrite" url="{R:1}/forum.php\?mod=forumdisplay&fid={R:2}&page={R:3}&{R:4}" /> </rule> <rule name="forum_viewthread"> <match url="^(.*/)*thread-([0-9]+)-([0-9]+)-([0-9]+).html\?*(.*)$" /> <action type="Rewrite" url="{R:1}/forum.php\?mod=viewthread&tid={R:2}&extra=page%3D{R:4}&page={R:3}&{R:5}" /> </rule> <rule name="group_group"> <match url="^(.*/)*group-([0-9]+)-([0-9]+).html\?*(.*)$" /> <action type="Rewrite" url="{R:1}/forum.php\?mod=group&fid={R:2}&page={R:3}&{R:4}" /> </rule> <rule name="home_space"> <match url="^(.*/)*space-(username|uid)-(.+).html\?*(.*)$" /> <action type="Rewrite" url="{R:1}/home.php\?mod=space&{R:2}={R:3}&{R:4}" /> </rule> <rule name="home_blog"> <match url="^(.*/)*blog-([0-9]+)-([0-9]+).html\?*(.*)$" /> <action type="Rewrite" url="{R:1}/home.php\?mod=space&uid={R:2}&do=blog&id={R:3}&{R:4}" /> </rule> <rule name="forum_archiver"> <match url="^(.*/)*(fid|tid)-([0-9]+).html\?*(.*)$" /> <action type="Rewrite" url="{R:1}/index.php\?action={R:2}&value={R:3}&{R:4}" /> </rule> </rules> </rewrite>三、服務(wù)器環(huán)境為服務(wù)器系統(tǒng)及 PHP : Linux / PHP v5.X.X 服務(wù)器軟件:Apache 這種環(huán)境也就是無憂主機(jī)php空間的環(huán)境,對應(yīng)的規(guī)則是:
RewriteEngine On # 修改以下語句中的 /discuz 為您的論壇目錄地址,如果程序放在根目錄中,請將 /discuz 修改為 / RewriteBase /discuz # Rewrite 系統(tǒng)規(guī)則請勿修改 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四、服務(wù)器系統(tǒng)及 PHP : Linux / PHP v5.X.X 服務(wù)器軟件:Nginx 這種環(huán)境對應(yīng)的規(guī)則為:
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 ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last; rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last; rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last; rewrite ^([^\.]*)/(fid|tid)-([0-9]+)\.html$ $1/index.php?action=$2&value=$3 last; if (!-e $request_filename) { return 404; }以上四種,就是常見的四類環(huán)境,站長朋友們可以根據(jù)自己的環(huán)境來配置discuz偽靜態(tài)。具體做法都是在配置文件中添加這些代碼,然后后臺開啟偽靜態(tài)功能,即可生效。希望對大家有所幫助。 無憂主機(jī)相關(guān)文章推薦閱讀: DISCUZ如何讓頂部導(dǎo)航固定 DISCUZ!X3.2支付寶充值亂碼BUG解決辦法 DISCUZ默認(rèn)域名設(shè)置失誤引起的鏈接錯誤問題
本文地址:http://www.gle-technology.com/discuz/20595.html