• Resolved goozo

    (@goozo)


    Hi,

    trying to sort out the rewite rules wordpress has generated for the url rewrite module of IIS. I also have an asp.net site so wordpress has to live together with the asp.net site. Everything is fine except that wordpress rewrite rules are messing with links to WebResource.axd for example there are some urls like this:

    http://www.mysite.com/WebResource.axd?d=PQkxjE-M5Qm8oTdmrs5VXIbiMce3MiBo9wMIzWEesTaF-Gd5-WllTvIrt8AJ3rl9vgtmGFYSEfaNkXlf1ND8mHEI9jM1&t=634604821351482412

    these return 404 not found error when I activate the 7 wordpress rewrite rules, listed here below, I suspect it is rule number 4. Any ideas on how I can fix this? Thanks!

    <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>
Viewing 10 replies - 1 through 10 (of 10 total)
  • This isn’t specifically an IIS issue, it’s that you’re trying to run WordPress Multisite, which needs to be able to rewrite URLs, in the same directory as another site. That would break your other site on Apache too.

    Multisite should be in the root directory on its own. Move your other site elsewhere and just use minimal redirection to catch /Webresource URLs before they hit Multisite’s rules.

    Thread Starter goozo

    (@goozo)

    Hi there, thanks for your answer but WP Multisite is installed in the root directory and everything is working fine with the asp.net site running in there too, url rewriting works fine for both WP and my other site, the *only* problem is the rewriting of specific urls to files which include webresource.axd I have found 2 other people on the net which have had this problem. I’m almost certain it will be a case of modifying wordpress rule 4 to exclude the .axd from the rule, I am currently working on the regex to do that and see if I can fix it. Any help from anyone having had to deal with this on IIS would be greatly appreciated!

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    Saying ‘it’s working fine except for this’ means ‘it’s not working completely’ which is what we’d expect to see.

    A handful of people use IIS and Multisite: https://www.google.com/search?sourceid=chrome&ie=UTF-8&q=wordpress+multisite+iis

    Good luck with modifying the rewrite rules, but I’d still avoid if possible. Your site will contain modified core files, require specialised maintenance knowledge and will be able to fail in hard-to-fix ways if your changes ever conflict with code base changes.

    Thread Starter goozo

    (@goozo)

    @dgilmour The web.config has to manually edited on IIS anyway, “The following is not true at all. Sorry. Nothing in core needs to be edited, this is standard stuff.

    Your site will contain modified core files, require specialised maintenance knowledge and will be able to fail in hard-to-fix ways if your changes ever conflict with code base changes.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    web.config == .htaccess 😉 Though I suspect what Dgilmour means is that using things other than the ‘default’ version of those files can cause weird issues. WHich is true, but sometimes it’s required due to server setups.

    Thread Starter goozo

    (@goozo)

    I do not think that’s what he meant. He is obviously not an IIS user. We’re not talking about wordpress files here, as you are rightly aware, we are talking about web.config rewrite rules. In any-case the ‘default’ version of web.config rewrite rules that wordpress multisite proposes currently do not work at all without manual modification, if you search for that you will see lots of people having to manually edit these rewrite rules generated for wordpress to avoid 404 errors. This is not a one off occurrence! I will post my solution here once I have it worked out so others can be helped.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    Oh I know, it’s just that I think that IIS does weird things.

    The default rules seem to work on about half the sites I’ve seen :/

    Yes, I’m not an IIS user, just trying to see if I could help. I didn’t know the history of WordPress proposing web.config rewrite rules that never work; that’s surprising.

    Ipstenu is right, I’m just trying to keep you on safe slopes because we’ve all seen reports of weirdness resulting from going people going off-piste with this. I try to think of essential code sections provided by applications as part of their core code and best kept unchanged if possible. Even if they’re held inside config files that are subject to other changes, I regard them as being inside the boundary of the WordPress system core. Clearly this is a case where that’s not an option.

    @goozo Good luck with sorting this, sorry I can’t be of any more help. Thanks for offering to share your fix.

    Thread Starter goozo

    (@goozo)

    @dgilmour no worries, thanks for your answer. I have now solved this by writing my own entry to wordpress rule 4 as suspected. Everything runs perfectly now. WordPress 3.3.1 Multisite in IIS 7.5 together with an existing asp.net site. hopefully this helps someone else too:

    You just need to add the following to wordpress rewrite rule 4.

    <add input="{URL}" pattern="([a-zA-Z0-9\./_-]+)\.axd" />

    so the resulting rewrite rule looks like this:

    <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" />
    <add input="{URL}" pattern="([a-zA-Z0-9\./_-]+)\.axd" />
    </conditions>
     <action type="None" />
     </rule>
Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Anyone using Multisite on IIS 7??’ is closed to new replies.