1、將下載的IIS Rewrite 組件解壓,放到適當的目錄(如 C:Rewrite)下,IIS Rewrite 組件下載 http://www.helicontech.com/download-isapi_rewrite.htm , IIS Rewrite 簡化版組件下載 http://www.newhua.com/soft/71446.htm ,下載下來解壓後不用安裝拷到目
1、將下載的IIS Rewrite 組件解壓,放到適當的目錄(如 C:Rewrite)下,IIS Rewrite 組件下載http://www.helicontech.com/download-isapi_rewrite.htm,IIS Rewrite 簡化版組件下載http://www.newhua.com/soft/71446.htm,下載下來解壓後不用安裝拷到目錄下設定好即可使用。
註:IIS Rewrite簡單使用方法介紹:一個功能強大的URL處理引擎,功能和Apache的 mod_Rewrite類似,這個是For IIS版本 可以把像list.asp?id=234 這樣的連結映射成 list/234.html 這樣就有利於在GG中的排名
完全版(Full)與簡化版(Lite)的最大的區別在於可以讓每個網站自訂URL重寫規則(Rewrite Rule),也就是只要將寫好的httpd.ini放在網站根目錄,就能使用了。
安裝說明:下載後可以解壓出 ISAPI_Rewrite.dll ,httpd.ini 這兩個檔案放到某個檔案夾下面,然後在 IIS 網站屬性的 ISAPI 中載入 ISAPI_Rewrite.dll 就可以了, httpd.ini 是設定檔裡面有例子。如果載入不成功的話 請給 ISAPI_Rewrite.dll 安全屬性為完全。
2、在“IIS管理器”裡選擇網站,右鍵,屬性。
3、選擇“ISAPI”,點擊“添加”。
4、填入篩選器名稱,如“rewrite”。
5、可執行檔下方點擊“瀏覽”,選擇剛才解壓的Rewrite組件位置,Rewrite.dll。
6、確認選擇正確後,點擊“確定”。
7、點擊“確定”,完成篩選器添加。
8、重啟IIS。
9、重啟IIS後,再次選擇網站,右鍵,屬性,看到如下所示向上的綠箭頭,說明 IIS Rewrite 成功添加並運行。
IIS Rewrite 規則設定
解壓後的 IIS Rewrite 組件目錄(如 C:Rewrite)中,有一個 httpd.ini 檔案,將相應規則寫入到這個檔案中即可。
1. 安裝重寫外掛程式Rewrite.dll
如果你的 IIS 伺服器載入過 Rewrite.dll 則可以不用下載。
Rewrite.dll檔案:百度搜尋索引鍵:Rewrite.dll 下載
載入 Rewrite.dll
在 IIS 的 Isapi 上添加篩選器
篩選器名稱為:re
可執行檔選擇 Rewrite.dll 就可以了!
2. 配置 httpd.ini
開啟你的httpd.ini,找到
[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
# Protect httpd.ini and httpd.parse.errors files
# from accessing through HTTP
RewriteRule ^(.*)/archiver/([a-z0-9-]+.html)$ $1/archiver/index.php?$2
RewriteRule ^(.*)/forum-([0-9]+)-([0-9]+).html$ $1/forumdisplay.php?fid=$2&page=$3
RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+).html$ $1/viewthread.php?tid=$2&extra=page%3D$4&page=$3
RewriteRule ^(.*)/profile-(username|uid)-(.+?).html$ $1/viewpro.php?$2=$3
以上是 Discuz!官方提供的配置代碼,注意正則格式。
3. 應用
比如,將read.php?bl_id=123&bu_id=456 偽靜態成 /html/123/456.html
可以這樣寫:
RewriteRule ^(.*)/html/([0-9]+)/([0-9]+).html$ $1/read.php?bl_id=$2&bu_id=$3
要使你的IIS伺服器支援偽靜態重寫,按以下步驟來:
1. 安裝重寫外掛程式Rewrite.dll
如果你的 IIS 伺服器載入過 Rewrite.dll 則可以不用下載。
載入 Rewrite.dll
在 IIS 的 Isapi 上添加篩選器
篩選器名稱為:re
可執行檔選擇 Rewrite.dll 就可以了!
2. 配置 httpd.ini
開啟你的httpd.ini,找到
[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
# Protect httpd.ini and httpd.parse.errors files
# from accessing through HTTP
RewriteRule ^(.*)/archiver/([a-z0-9-]+.html)$ $1/archiver/index.php?$2
RewriteRule ^(.*)/forum-([0-9]+)-([0-9]+).html$ $1/forumdisplay.php?fid=$2&page=$3
RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+).html$ $1/viewthread.php?tid=$2&extra=page%3D$4&page=$3
RewriteRule ^(.*)/profile-(username|uid)-(.+?).html$ $1/viewpro.php?$2=$3
以上是 Discuz!官方提供的配置代碼,注意正則格式。
3. 應用
比如,將read.php?bl_id=123&bu_id=456 偽靜態成 /html/123/456.html
可以這樣寫:
RewriteRule ^(.*)/html/([0-9]+)/([0-9]+).html$ $1/read.php?bl_id=$2&bu_id=$3
再例:
123.php?id=123
123/id/123
RewriteRule ^123/id/([0-9][0-9][0-9])/$ /123.php?id=$1
or
RewriteRule ^123/id/([0-9]+)$ /123.php?id=$1
PW的規則:[ISAPI_Rewrite]
RewriteRule ^(.*)-htm-(.*)$ $1.php?$2
RewriteRule ^(.*)/simple/([a-z0-9_]+.html)$ $1/simple/index.php?$2
註:比如互動百科的偽靜態,設定方法和這些都是差不多的,學會這個方法了其它的一些系統的偽靜態設定都是差不多的,不同的可能就是偽靜態規則設定會不一樣。
個人記事:
這裡的$1, $2, $3就是前一個運算式的匹配值
比如:
^(.*)/simple/([a-z0-9_]+.html)$ $1/simple/index.php?$2