使用web.config为查询字符串中的多个变量重写url

时间:2014-01-09 16:51:59

标签: iis web-config friendly-url

我正在尝试使用web.config创建frindly URL,并且它必须从1重写(可能)2个变量并忽略重写(如果它是目录名称)。所以我有这个网址:

http://www.domain.com/2014/ - Where 2014 is a folder.
http://www.domain.com/2014/publications/ - It's one of the possible URLs
http://www.domain.com/2014/publications/news/ - Another possible URL

虽然真正的网址是

http://www.domain.com/2014/
http://www.domain.com/2014/?page=publications
http://www.domain.com/2014/?page=publications&subpage=news

我正在尝试这个web.config但是我收到错误500.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Friendly 2">
                    <match url="^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$" ignoreCase="false" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="/2014/index.php?page={R:1}&subpage={R:2}" appendQueryString="false" />                  
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

我错过了什么吗?

提前致谢!

0 个答案:

没有答案