1

我想在我的应用程序上使用漂亮的 url。我正在使用 Yii 1.1(Php 框架)和 IIS 7.5

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>

<directoryBrowse enabled="false" />

    <rewrite>
        <rules>
        <rule name="Hide Yii Index" stopProcessing="true">
            <match url="." ignoreCase="false" />
            <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
            </conditions>
                <action type="Rewrite" url="index.php" appendQueryString="true" />
        </rule> 
        </rules>
    </rewrite>

</system.webServer> 
</configuration>

我已经像这样配置了我的 IIS 重写规则。但是不行。有人知道为什么吗?

4

2 回答 2

0

我认为您在 web.config 中插入以下代码

 <serverVariables>
      <set name="REQUEST_URI" value="{UNENCODED_URL}"  replace="true" />
 </serverVariables>

结果:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="WordPress Rule" stopProcessing="true">
                    <match url=".*" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php" />
                    <serverVariables>
                        <set name="REQUEST_URI" value="{UNENCODED_URL}" replace="true" />
                    </serverVariables>
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

此问题主要发生在波斯语和阿拉伯语中,主要用于 wordpress 网站

于 2017-07-08T12:10:22.560 回答
0

尝试

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

    <configSections>
        <sectionGroup name="system.webServer">
            <sectionGroup name="rewrite">
                <section name="rewriteMaps" overrideModeDefault="Allow" />
                <section name="rules" overrideModeDefault="Allow" />
            </sectionGroup>
        </sectionGroup>
    </configSections>

    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Imported Rule 1" stopProcessing="true">
                    <match url="^(.*)$" ignoreCase="false" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php" />
                </rule>
            </rules>
        </rewrite>

    </system.webServer>
</configuration>
于 2017-07-05T04:44:49.060 回答