Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm having an interesting issue with the migration to wordpress 3.1.1 multisite and the url rewrite rules. the index.php routing, as well as the ms-files.php?file= rules are failing across the board. The ROOT site has functionality thats working, when you route the permalinks through index.php. (edit: This is also prevalent in the network sites, From what I can see Rule 7 is the culprit on failure here.)

The rule for media (rule2) is failing as well. The generated link is pulling back a "oops cannot be found" 404 style error.

Everything looked proper in the rules section, appended below:

           <rule name="WordPress Rule 1" stopProcessing="true">
                <match url="^index\.php$" ignoreCase="false" />
                <action type="None" />
            </rule>
            <rule name="WordPress Rule 2" stopProcessing="true">
                <match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" />
                <action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" />
            </rule>
            <rule name="WordPress Rule 3" stopProcessing="true">
                <match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" />
                <action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" />
            </rule>
            <rule name="WordPress Rule 4" stopProcessing="true">
                <match url="^" ignoreCase="false" />
                <conditions logicalGrouping="MatchAny">
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
                </conditions>
                <action type="None" />
            </rule>
            <rule name="WordPress Rule 5" stopProcessing="true">
                <match url="^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*)" ignoreCase="false" />
                <action type="Rewrite" url="{R:1}" />
            </rule>
            <rule name="WordPress Rule 6" stopProcessing="true">
                <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
                <action type="Rewrite" url="{R:2}" />
            </rule>
            <rule name="WordPress Rule 7" stopProcessing="true">
                <match url="." ignoreCase="false" />
                <action type="Rewrite" url="index.php" />
            </rule>

You can view the exhibited behavior by vising: UB News Staging site 1 UB News Staging Site 2

Notice on staging site 2 how the media does not function correctly. However when you visit the following link, the format is working and the photo is displaying like it should. http://staging.business-school-online.com/news/wp-includes/ms-files.php?file=2011/04/online-education-300x198.jpg

edit: The WP generated link is http://staging.business-school-online.com/news/files/2011/04/online-education-300x198.jpg

Can someone offer some insight into the failing url-rewrite rule? according to regex buddy the structure is correct. Regex Explanation

share|improve this question

1 Answer 1

up vote 2 down vote accepted

I haven't worked with the wordpress links per se, but let's start with the media rule. There appear to be 2 things missing in the action. It doesn't have the /news/, which is available in {R:1}, and it doesn't account for the -300x198. Not accounting for the image size, this would take care of the root:

<rule name="WordPress Rule 2" stopProcessing="true">
   <match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" />
   <action type="Rewrite" url="{R:1}wp-includes/ms-files.php?file={R:2}" appendQueryString="false" />
</rule>

For the image size, if you can edit your original links that would be ideal, otherwise your match url will just need to pull out the .jpg, and in the action add the image size plus .jpg specifically.

Three good options for troubleshooting this are:

  • Failed Request Tracing, it will show before and after paths for the rules
  • The IIS logs will show what path was attempted. For example, this should show something like "wp-includes/ms-files.php?file=2011/04/online-education.jpg"
  • Procmon from www.sysinternals.com will show what path it's trying to access on disk.
share|improve this answer
    
Unfortunately this did not help. I'm still receiving 404's on the links/files. However that did seem like a solid answer. –  lazyPower Apr 19 '11 at 18:22
    
after abandoning this and revisiting several weeks later, i vaped the rules, and rewrote them according to this guide and PRESTO they worked! Thanks Scott. Apologies on the delayed acceptance when you were 100% correct from the word go –  lazyPower May 4 '11 at 16:40
    
Hi @lazyPower. Excellent, glad that you got it working! Thanks for the update. –  Scott Forsyth - MVP May 4 '11 at 18:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.