WIN IIS7.0 Rewrite 僞靜態設置使用說明

WIN IIS7.0 Rewrite 僞靜態設置使用說明【godaddy WIN .NET/PHP空間IIS7.0僞靜態設置】
網站根目錄建立 Web.Config 配置文件(文件名大小寫敏感!)
Web.Config 添加規則:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
	<system.webServer>
    	<rewrite>
        	<rules>
            	<rule name="Rewrite to index.php" stopProcessing="true">
                	<match url="^index.html" />
                	<action type="Rewrite" url="index.php"  />
                </rule>
                <rule name="Rewrite to article.php" stopProcessing="true">
                	<match url="^article_(\d+).html" />
                    <action type="Rewrite" url="article.php?id={R:1}" />
                </rule>
                <rule name="Rewrite to list.php" stopProcessing="true">
                	<match url="^list_(\d+)_(\d+).html" />
                    <action type="Rewrite" url="list.php?id={R:1}&amp;page={R:2}" />
                </rule>
                <rule name="Rewrite to sitemap.php" stopProcessing="true">
                	<match url="^sitemap.xml" />
                    <action type="Rewrite" url="sitemap.php"  />
                </rule>
        	</rules>
    	</rewrite>
	</system.webServer>
</configuration>
 

保存修改!


建立 index.php:
<?php
echo "Hello World!";
?>


測試:
http://網址/index.html,如網頁中有Hello World!則配置成功!如需要可以配置更多的規則!
上述是針對PHP配置的規則,ASP.NET同理!

注:
1、配置文件名Web.Config大小寫注意;
2、Web.Config必須放到網站根目錄;
3、規則一定要寫正確,多個傳值時“&”在規則中是“&amp;”;
4、在僞靜態前一定要看看空間支持哪種方式的靜態,查看phpinfo();Server API是CGI/FastCGI還是Apache Handler,僞靜態文件是httpd.ini或.htaccess或Web.Config。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章