• Couple notes up-front: This is a WP site hosted in Azure (so it’s behind IIS), and I use a web.config for all below url rewrite rules, not an htaccess file.

    So I’ve recently moved a website I host for a client (www.sondheimreview.com) behind SSL completely, and created a couple SEO-friendly friendly rules:
    1. Send any non-www URL’s (https://sondheimreview.com) to the WWW address (https://www.sondheimreview.com)
    2. Enforce HTTPS for any non-HTTPS requests.
    3. Enforcing all lower-case URL’s
    4. Remove trailing slashes on all URL’s

    Some pretty sick stuff. Tested it all on a plain non-CMS, non-WordPress site, and it all works 100% great. Apply it on the WP site (www.sondheimreview.com), and though some rules seem to work some of the time (www rule works, and HTTPS rule works), lower-casing URL’s does NOT work, and removing trailing slashes also does NOT work.

    Also — and this is the most annoying one — if you try to hit some non-homepage URL on the site, ie: https://www.sondheimreview.com/our-story-parent/about-us/ , either as non-www, or without HTTPS (http), the user is redirected to the homepage, instead of the same URL but with the www-only and HTTPS-only rules applied.

    My guess for that last super annoying piece is this little piece of URL rewrite logic, intended for enabling pretty permalinks:
    <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"/>

    The above seems to be pretty standard, and seems to be recommended widely (here, for example).

    Sorry for the long write-up (I like to be detailed), but finally here is the question:
    How does I fix the rules to make non-homepage URL’s be properly rewritten according to my rules, and not send insane amounts of links (every non-www or non-https link out there) back to the Homepage?

    Is the above pretty URL permalink URL rewrite necessary? What is it intended to achieve, specifically — I apologize, but I don’t exactly understand its purpose, or its end result. Obviously I would like to either remove it, or somehow make it work alongside the www-only and HTTPS-only rewrite rules I have setup.

    Thanks for any help!

  • The topic ‘WP ignores or redirects to homepage for web.config URL rewrite rules’ is closed to new replies.