简体   繁体   中英

Wordpress url rewriting does not work on iis7

I have a Wordpress website running on IIS7.

I had a big problem because all my url except the home page contain index.php.

My home page : www.mywebsite.com Others : www.mywebsite.com/index.php/post1, www.mywebsite.com/index.php/post2 and so..

I'd like to use the url rewriting mode of IIS7. My web host told me that the rewriting module is activated.

I don't know what to write in web.config file. 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 ?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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