Make WordPress Core

Opened 14 months ago

Last modified 9 months ago

#56381 new defect (bug)

WordPress creates invalid web.config -file

Reported by: liskoslayer63's profile liskoslayer63 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.0
Component: Rewrite Rules Keywords: needs-testing
Focuses: Cc:

Description

When WP creates the web.config file for URL Rewrite, it uses apparently wrong syntax in the file. In the file that WordPress creates, it has this line: <match url="*"/> when it should have this: <match url="(.*)"/>.

This causes very odd behavior on the site, mainly because of Internal Server Error 500. The weird part is, that all image links that uses the plain name causes that error, but if you add the size to the url (eg. /file.jpg -> file-150x150.jpg) the error goes away and the image loads normally.

Ihad zero plugins installed when this occured. Tried also generating the file multiple times, always the same bug except when using "Plain" for url's.

I have Googled a lot, and found that there's many people who's suffering from that exact behavior at least from version 5.6. I do not know if they used IIS (Windows) for hosting, but if the used, then that web.config file is the reason on that case.

Change History (4)

#1 @liskoslayer63
14 months ago

That fixes the image links yeah, but now every other page shows 404 error, so really can't say what is going on.

Finally managed to get it working with this:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="WordPress Rule" patternSyntax="Wildcard" 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?page_id={R:0}"/>
        </rule>
        <rule name="wordpress" patternSyntax="Wildcard" 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"/>
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>
Last edited 14 months ago by liskoslayer63 (previous) (diff)

#2 @SergeyBiryukov
14 months ago

  • Keywords needs-testing added

Hi there, welcome to WordPress Trac! Thanks for the ticket.

The rule in question appears to be added twelve years ago in [14885] / #12758, and it may indeed not work with newer IIS versions. Could you share the IIS version you're using?

If any other contributors looking at this ticket use IIS, some more testing to confirm the issue and the solution would be helpful to move the ticket forward.

This ticket was mentioned in Slack in #hosting-community by chaion07. View the logs.


9 months ago

This ticket was mentioned in Slack in #hosting-community by jadonn. View the logs.


9 months ago

Note: See TracTickets for help on using tickets.