隐藏

WIN IIS7.0 Rewrite 伪静态设置使用说明

发布:2013/5/4 16:46:16作者:管理员 来源:本站 浏览次数:2368

 

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大小写注意;
2Web.Config必须放到网站根目录;
3、规则一定要写正确,多个传值时“&”在规则中是“&amp;”
4、在伪静态前一定要看看空间支持哪种方式的静态,查看phpinfo();Server APICGI/FastCGI还是Apache Handler,伪静态文件是httpd.ini/.htaccess/Web.Config