一、先到IIS官方下載模塊
下載地址:http://www.iis.net/download/URLRewrite
二、安裝重寫模塊
我下載的是本地exe文件,雙擊安裝便可(若是IIS服務沒停的話,安裝完成後會要求重啓系統。)
三、這個時候再進 「Internet 信息服務(IIS)管理器」,就能夠看見模塊中多了一個 Url Rewrite 模塊,進入須要設置僞靜態的相關站點。
四、進入須要設置的站點,雙擊 Url Rewrite 圖標,進入設置界面。
而後點擊右側的「導入規則「
五、導入規則文件:.htaccess
點擊「導入」此文件
(沒有.htaccess 能夠下載一個phpcms v9 ,導入其中的.htaccess)
六、確認無誤後,點擊右欄的「應用」按鈕便可php
ps:html
配置完僞靜態後發現網站全部的連接都不跳轉,都顯示首頁。找了好多資料,摸索了一個上午,最終發現仍是規則文件的問題。web
下面經常使用的 web.config 配置僞靜態的方法。windows
第一種方法:web.configapi
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="OrgPage" stopProcessing="true"> <match url="^(.*)$" /> <conditions logicalGrouping="MatchAll"> <add input="{HTTP_HOST}" pattern="^(.*)$" /> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> </conditions> <action type="Rewrite" url="index.php/{R:1}" /> </rule> </rules> </rewrite> </system.webServer> </configuration>
第二種方法:web.config<?xml version="1.0" encoding="UTF-8"?>工具
<configuration> <system.webServer> <rewrite> <rules> <rule name="規則 1" stopProcessing="true"> <match url="^includes/(.*)" /> <action type="Rewrite" url="includes\/{R:1}" /> </rule> <rule name="規則 2" stopProcessing="true"> <match url="^(blog)/includes/(.*)" /> <action type="Rewrite" url="{R:1}/includes\/{R:2}" /> </rule> <rule name="規則 3" stopProcessing="true"> <match url="^(blog)/(.*).html(.*)" /> <action type="Rewrite" url="{R:1}/index.php\/{R:2}.html{R:3}" /> </rule> <rule name="規則 4" stopProcessing="true"> <match url="^(.*).html(.*)" /> <action type="Rewrite" url="index.php\/{R:1}.html{R:2}" /> </rule> </rules> </rewrite> </system.webServer> </configuration>
以上的 URL重定向 規則,咱們也能夠自行定義,能夠經過在線轉換工具生成 http://www.webweb.com/htaccesstowebconfig/ 網站
ps:url
windows2008 iis7 僞靜態URL中帶特殊符號空格沒法訪問的解決辦法spa
打開 web.config:
修改爲如下格式.net
<configuration> <system.webServer> <security> <requestFiltering allowDoubleEscaping="true"></requestFiltering> </security> </system.webServer> </configuration>