Discuz! X2子目錄偽靜態的實現方法
來源:易賢網 閱讀:1046 次 日期:2014-09-04 14:46:16
溫馨提示:易賢網小編為您整理了“Discuz! X2子目錄偽靜態的實現方法”,方便廣大網友查閱!

前幾天幫人實現Discuz X2的子目錄偽靜態,以前沒做過,就去查了下百度和Discuz論壇,發現好多人都在找這樣的偽靜態方法,可是都沒真正能解決的方法。

Discuz X2現在用的人還是比較多的,我不知道有多少人用的是IIS7的,用Apache的就好辦一些,因為.hacess是可以設置子目錄的偽靜態規則的,但是 在IIS7下,webconfig究竟怎么放才能實現子目錄偽靜態沒有試過,我百度的時候還有人說IIS7是Discuz X2的非主流環境。

下面我就說一下在IIS7下如何實現Discuz X2的子目錄偽靜態。

首先說明一下,在IIS7下我們自己測試的時候之所以不能實現,大部分是因為我們把偽靜態的文件放在子目錄了,造成主目錄的規則跟子目錄相互沖突。

還有一些是在子目錄消除了主目錄的偽靜態繼承,但是依舊打不開。

我通過多次測試發現,IIS7下的子目錄偽靜態,規則要放在主目錄,而且規則的寫法不能跟主目錄的規則沖突。我這里就不說那么多理論了。直接發規則:

<?xml version="1.0" encoding="UTF-8"?>

<configuration>

<system.webServer>

<rewrite>

<rules>

<rule name="WWW 301Redirect" stopProcessing="true"> // 301跳轉規則

<match url=".*" />

<conditions>

<add input="{HTTP_HOST}" pattern="^domain.comg$" />

</conditions>

<action type="Redirect" url="http://www.domain.com/{R:0}" redirectType="Permanent" />

</rule>

<rule name="portal_topic"> // 論壇規則開始

<match url="^(.*)/topic-(.+).html?*(.*)$" />

<action type="Rewrite" url="{R:1}/portal.php?mod=topic&amp;topic={R:2}&amp;{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&amp;aid={R:2}&amp;page={R:3}&amp;{R:4}" />

</rule>

<rule name="forum_forumdisplay">

<match url="^(.*)/forum-(w+)-([0-9]+).html?*(.*)$" />

<action type="Rewrite" url="{R:1}/forum.php?mod=forumdisplay&amp;fid={R:2}&amp;page={R:3}&amp;{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&amp;tid={R:2}&amp;extra=page%3D{R:4}&amp;page={R:3}&amp;{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&amp;fid={R:2}&amp;page={R:3}&amp;{R:4}" />

</rule>

<rule name="home_space">

<match url="^(.*)/space-(username|uid)-(.+).html?*(.*)$" />

<action type="Rewrite" url="{R:1}/home.php?mod=space&amp;{R:2}={R:3}&amp;{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&amp;uid={R:2}&amp;do=blog&amp;id={R:3}&amp;{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}&amp;value={R:3}&amp;{R:4}" />

</rule> //論壇規則結束

<rule name="wordpress" patternSyntax="Wildcard"> // WP偽靜態規則開始

<match url="*" />

<conditions>

<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />

<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />

<add input="{REQUEST_URI}" pattern="^/bbs1" negate="true" />

</conditions>

<action type="Rewrite" url="index.php" />

</rule>

</rules>

</rewrite>

</system.webServer>

</configuration>

基本上這個規則的子目錄已經確定是bbs了,實在不會的朋友直接抄襲吧。

更多信息請查看IT技術專欄

更多信息請查看CMS教程
易賢網手機網站地址:Discuz! X2子目錄偽靜態的實現方法
由于各方面情況的不斷調整與變化,易賢網提供的所有考試信息和咨詢回復僅供參考,敬請考生以權威部門公布的正式信息和咨詢為準!
相關閱讀CMS教程

2026國考·省考課程試聽報名

  • 報班類型
  • 姓名
  • 手機號
  • 驗證碼
關于我們 | 聯系我們 | 人才招聘 | 網站聲明 | 網站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
工業和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網安備53010202001879號 人力資源服務許可證:(云)人服證字(2023)第0102001523號
云南網警備案專用圖標
聯系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關注公眾號:hfpxwx
咨詢QQ:1093837350(9:00—18:00)版權所有:易賢網
云南網警報警專用圖標
未满十八18勿进黄网站免费看