IIS投掷'错误请求'

时间:2013-03-25 21:02:06

标签: php iis mod-rewrite iis-7 routing

基本上我将所有请求发送到index.php,因此http://example.com/article等于http://example.com/index.php?page=article

它适用于mod_rewrite,但是对于IIS7(web.config),它不适用于特定情况。

APACHE ( mod_rewrite / .htaccess )

    http://example.com/members .... Works!
    http://example.com/article&id=1 .... Works!

但是...

IIS ( web.config )
    http://example.com/members .... Works!
    http://example.com/article&id=1 .... 'Bad Request'

我将如何解决这个问题?

我的.htaccess

RewriteEngine on

RewriteBase /
RewriteCond  %{REQUEST_FILENAME} !-f
RewriteCond  %{REQUEST_FILENAME} !-d
RewriteRule  ^(.*)$ index.php?page=$1 [QSA,L]

我的web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <clear />
                <rule name="Imported Rule 1-1" stopProcessing="true">
                    <match url="^buddy" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="None" />
                </rule>
                <rule name="Imported Rule 1">
                    <match url="^(|/)$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="Rewrite" url="index.php?page={R:1}" appendQueryString="false" />
                </rule>
                <rule name="Imported Rule 2">
                    <match url="^([a-zA-Z0-9/_-]+)(|)$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="Rewrite" url="index.php?page={R:1}" appendQueryString="false" />
                </rule>
            </rules>
        </rewrite>
        <defaultDocument>
            <files>
                <remove value="iisstart.htm" />
                <remove value="Default.asp" />
                <remove value="Default.htm" />
            </files>
        </defaultDocument>
    </system.webServer>
</configuration>

先谢谢!

0 个答案:

没有答案