简体   繁体   English

WordPress网址重写在iis7上不起作用

[英]Wordpress url rewriting does not work on iis7

I have a Wordpress website running on IIS7. 我有一个在IIS7上运行的Wordpress网站。

I had a big problem because all my url except the home page contain index.php. 我遇到了一个大问题,因为除主页外,我所有的URL都包含index.php。

My home page : www.mywebsite.com Others : www.mywebsite.com/index.php/post1, www.mywebsite.com/index.php/post2 and so.. 我的主页:www.mywebsite.com其他:www.mywebsite.com/index.php/post1、www.mywebsite.com/index.php/post2等。

I'd like to use the url rewriting mode of IIS7. 我想使用IIS7的URL重写模式。 My web host told me that the rewriting module is activated. 我的网络主机告诉我重写模块已激活。

I don't know what to write in web.config file. 我不知道在web.config文件中写什么。 I've tried : 我试过了 :

<?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>

My url does not change ! 我的网址没有改变!

and this : 和这个 :

<?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>

I've also tried: 我也尝试过:

<?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>

Always does not work. 始终不起作用。

Could you help me to remove index.php in the url please ? 您能帮我从URL中删除index.php吗?

<?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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM