標籤:tool amp 朋友 網址 ref url 方法 tab 注意
IIS 7和IIS 7.5及以後的版本估計都會使用web.config來實現偽靜態規則,於是我們以前的偽靜態檔案必須更改。網上找了一圈,還沒有發現比較全面的web.config偽靜態規則,於是我們這裡整理一份,供初次使用的朋友參考。
實現普通頁面、帶一個數字參數頁面和帶兩個參數頁面的偽靜態!
?
| 12345678910111213141516171819202122232425 |
<?xml version="1.0" encoding="UTF-8"?><configuration><system.webServer><rewrite><rules> <rule name="Index" stopProcessing="true"><match url="^index.html" /><action type="Rewrite" url="index.php" /></rule> <rule name="Rule1" stopProcessing="true"><match url="^news_([0-9]+).html" /><action type="Rewrite" url="news.php?nid={R:1}" /></rule> <rule name="Rule2" stopProcessing="true"><match url="news_list_([0-9]+)_([0-9]+).html" /><action type="Rewrite" url="news_list.php?nid={R:1}&page={R:2}" /></rule> </rules></rewrite></system.webServer></configuration> |
IIS 7.5通過web.config實現301重新導向的方法,將不帶www的網域名稱轉向到帶www的網域名稱上!
?
| 123456789101112131415161718 |
<?xml version="1.0" encoding="UTF-8"?><configuration><system.webServer><rewrite><rules> <rule name="Redirect" stopProcessing="true"><match url=".*" /><conditions><add input="{HTTP_HOST}" pattern="^chuangluo.com$" /></conditions><action type="Redirect" url="http://www.chuangluo.com/{R:0}" redirectType="Permanent" /></rule> </rules></rewrite></system.webServer></configuration> |
由於我們的網站使用了逸出字元,因此在實際使用的時候,大家不可以直接複製以上代碼。請複製粘貼到Dreamweaver等編輯器後,使用替換功能把雙引號全部替換為英文狀態下的雙引號,然後再修改rule標籤內的內容就可以了,跳轉的地方請更改為自己的網址即可。
需要注意的地方是以前httpd.ini和.htaccess支援網址中兩個參數用&符號連結,在web.config中是不支援的,需要將這個符號更改為&才能正常使用。
原文連結:http://www.jb51.net/article/42901.htm
IIS7.5使用web.config設定偽靜態方法