URL Redirect Loop from domain.com to www.domain.com—multisite/subdirectory IIS7
-
All our blogs are of URL pattern https://www.mydomain.com/blogs/myblogname . If someone requests one of these blogs with a URL pattern that omits the https://www., it results in a too many redirects browser error. Our “home” url in wp_options does indeed specify the www.
Our complete web.config file is pasted below. Note that the first rule, the “Add WWW prefix,” does absolutely nothing as far as I can tell.
This isn’t a web.config I wrote, I’m not really a WP programmer, and I’ve had a devil of a time trying to search the web for what would be a good web.config for my particular setup, so I feel like I’m just flailing blindly. For like a week. I would be enormously grateful for troubleshooting help. Thank you.
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="Add WWW prefix" enabled="true" stopProcessing="true"> <match url="(.*)" ignoreCase="true" /> <conditions> <add input="{HTTP_HOST}" pattern="^mydomain\.com" /> </conditions> <action type="Redirect" url="https://www.mydomain.com/blogs/{R:1}" /> </rule> <rule name="WordPress Rule 1" enabled="true" stopProcessing="true"> <match url="^index\.php$" ignoreCase="false" /> <action type="None" /> </rule> <rule name="WordPress Rule 2" enabled="true" 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" enabled="true" 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" enabled="true" 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" enabled="true" stopProcessing="true"> <match url="^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*)" ignoreCase="false" /> <action type="Rewrite" url="{R:2}" /> </rule> <rule name="WordPress Rule 6" enabled="true" stopProcessing="true"> <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" /> <action type="Rewrite" url="{R:2}" /> </rule> <rule name="WordPress Rule 7" enabled="true" stopProcessing="true"> <match url="." ignoreCase="false" /> <action type="Rewrite" url="index.php" /> </rule> </rules> </rewrite> </system.webServer> </configuration>
Other misc data points:
- If I change my Add WWW Prefix rule’s redirect URL to https://test.com/?urlstring=https://www.mydomain.com/blogs/{R:1} , I’m redirected to https://test.com/?urlstring=https://www.mydomain.com/blogs/nk/ as you’d expect.
- If I change my Add WWW Prefix rule’s redirect URL to https://www.mydomain.com/r/path=blogs/{R:1} , I’m redirected to https://mydomain.com/r/path=blogs/nk/ . WHAT EVEN. I mean this is nice to know as a worst-case scenario because I can hand-write a custom redirect page there, but what a trainwreck hack that’d be, and more importantly, WHERE DID MY WWW. GO? I have zero rewrite rules at the IIS site root or server parent node levels.
- Is stopProcessing=”true” even valid for a redirect rule, rather than a rewrite rule? I ask because I’m not seeing any UI to control that value in IIS for redirects. Only for rewrites.
I, just, agh, help.
- The topic ‘URL Redirect Loop from domain.com to www.domain.com—multisite/subdirectory IIS7’ is closed to new replies.