Wordpress网址重写不适用于iis7

时间:2012-10-18 21:13:19

标签: wordpress iis-7 url-rewriting

我在IIS7上运行了一个Wordpress网站。

我遇到了一个很大的问题,因为我的所有网址除主页外都包含index.php。

我的主页:www.mywebsite.com 其他:www.mywebsite.com/index.php/post1,www.mywebsite.com/index.php/post2等..

我想使用IIS7的url重写模式。我的网站主持人告诉我,重写模块已激活。

我不知道在web.config文件中写什么。我试过了:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="wordpress" patternSyntax="Wildcard">
                    <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"/>
                </rule>     
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

我的网址不会改变!

和此:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Supprimer index.php">
                    <match url="^index.php/([_0-9a-z-]+)/([_0-9a-z-]+)" />
                    <action type="Rewrite" url="{R:1}/{R:2}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

我也试过了:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Main Rule" stopProcessing="true">
                    <match url=".*" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php/{R:0}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

始终不起作用。

你能帮我删除网址中的index.php吗?

1 个答案:

答案 0 :(得分:1)

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <httpErrors errorMode="Detailed"/>
    <rewrite>
      <rules>
        <rule name="Main Rule" stopProcessing="true">
        <match url=".*"/>
            <conditions logicalGrouping="MatchAll">
                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
            </conditions>
        <action type="Rewrite" url="index.php/{R:0}"/></rule>
            <rule name="wordpress" patternSyntax="Wildcard">
                <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"/>
        </rule>     
        </rules>
    </rewrite>
    <defaultDocument>
      <files>
        <clear/>

        <add value="index.php"/>
      </files>
    </defaultDocument>
  </system.webServer>
</configuration>