简体   繁体   中英

URL Rewrite IIS and Wordpress

I have this following web.conf

<?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>
        <defaultDocument>
            <files>
                <clear />
                <add value="index.php" />
                <add value="Default.htm" />
                <add value="Default.asp" />
                <add value="index.htm" />
                <add value="index.html" />
                <add value="iisstart.htm" />
                <add value="default.aspx" />
            </files>
        </defaultDocument>

  </system.webServer>
</configuration>

The wordpress site works, however some images I get the following error if I view an image example http://domain/wp-content/uploads/2018/06/home-slide-5.jpg

HTTP Error 500.50 - URL Rewrite Module Error. The page cannot be displayed because an internal server error has occurred.

I have added the following to the rules now it seems to work

<rule name="Imported Rule 1" stopProcessing="true">
    <match url="^index\.php$" ignoreCase="false"/>
    <action type="None"/>
</rule>

<rule name="Redirect Image to HTTP" stopProcessing="true">
    <match url=".*\.(gif|jpg|jpeg|png|css|js)$" ignoreCase="true"/>
    <action type="Rewrite" url="{R:0}"/>
</rule>

<rule name="Imported Rule 2" 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>

CREDITS: Wordpress permalinks on IIS?

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