IIS7.5使用web.config設定偽靜態方法

來源:互聯網
上載者:User

標籤: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設定偽靜態方法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.