• Hello!

    I’m running a WordPress install in a subfolder on one of my client’s sites. The server is IIS I’m pretty sure (it uses a web.config file instead of an .htaccess) and I’m having issues getting the site home page (set to show the latest posts) to show up without the trailing slash at the end of the url. The site works fine with the / at the end of the url, but without it, the site redirects back to the main site on the domain (the non-Wordpress site that’s not in the subfolder).

    Anyway, I’m pretty sure this issue is IIS related, but have spent time researching and testing and what I’ve found isn’t working. Any help would be appreciated, thanks!

Viewing 12 replies - 1 through 12 (of 12 total)
  • Moderator Marius L. J.

    (@clorith)

    Hiya,

    This sounds like a simple pattern issue in your web.config file, if you are still having this issue, could you perhaps share the content of this file with us?

    Thread Starter sweettea2

    (@sweettea2)

    Sure! Below is the code that’s in the /blog/ subfolder with the WordPress files. Do you need the code from the main folder web.config as well?

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <system.webServer>
       <rewrite>
        <rules>
            <rule name="Main Rule" stopProcessing="true">
                <match url=".*" />
                <conditions logicalGrouping="MatchAll">
                    <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>
    Moderator Marius L. J.

    (@clorith)

    Hi,

    Nah this should be sufficient, it’s peculiar that it isn’t working as this one seems like it -should- catch everything, but we can try a slight edit that might fix it.

    Change <match url=".*" /> to instead read <match url=".*\/?" />

    It’s a bit of a shot in the dark as it shouldn’t matter, but I also know that IIS some times does strange things, so this is a great first step in troubleshooting it at least ??

    Thread Starter sweettea2

    (@sweettea2)

    Unfortunately, that didn’t seem to fix the issue. I still wonder if something in the main site’s web.config is causing this? I’ve posted a snippet from the main web.config below (didn’t post the whole file for security reasons). Thanks again for your assistance!!

    <system.webServer>?
    ??? <rewrite>
    ??? <rules>
    ??????? <rule name="Redirect domain.com to www" patternSyntax="Wildcard" stopProcessing="true">
    ??????????? <match url="*" />
    ??????????? <conditions>
    ??????????????? <add input="{HTTP_HOST}" pattern="example.com" />
    ??????????? </conditions>
    ??????????? <action type="Redirect" url="https://www.example.com/{R:0}" />
    ? </rule>
    </rules>
    </rewrite>
    </system.webServer>
    Moderator Marius L. J.

    (@clorith)

    That’s just a www redirector, I don’t see it as being the source of this.

    Is the site in the root location also a WP site, or is this something completely different ?

    Thread Starter sweettea2

    (@sweettea2)

    Ok. No, the site in the root location is a custom php site (non-WP).

    Moderator Marius L. J.

    (@clorith)

    Hmmm…

    On your WordPress site, could you show how your permalinks are configured (the most efficient approach here is to take a screenshot of the Settings > Permalinks screen) ?

    Thread Starter sweettea2

    (@sweettea2)

    Link to Screenshot

    Above is a link to a screenshot of the Permalinks page. Also, the plugins I have active on the site are:

    • Attachment Pages Redirect
    • Disable Comments
    • Easy Author Image
    • Easy Updates Manager
    • Google XML Sitemaps
    • Quick Page/Post Redirect Plugin
    • Sucuri
    • Wordfence
    • WP Sitemap Page
    • Yoast SEO

    Thanks again for all your assistance!!

    Moderator Marius L. J.

    (@clorith)

    Hmm,

    The permalinks etc seem fine, but I am wondering if one of those redirect plugins might be the cause of this.

    Could you try it without any plugins active for a moment and see what happens (You may want to disable any plugins, then go to Settings > Permalinks, hit save twice and then see if it works)

    Thread Starter sweettea2

    (@sweettea2)

    I got it to work!!!!! This link and this link got me on the right track and so the final web.config code that works is below for reference. I really appreciate your patience and assistance. All the best!

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <system.webServer>
    
    	<defaultDocument enabled="false" />
    	<rewrite>
          <rules><rule name="Main Rule" stopProcessing="true"><match url=".*"/><conditions logicalGrouping="MatchAll"><add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/><add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/></conditions><action type="Rewrite" url="index.php"/></rule>
    
    			<rule name="No slash root" enabled="true" stopProcessing="true">
                <match url="^$" />
                <action type="Rewrite" url="index.php" />
            </rule>
    			</rules>
        </rewrite>
      </system.webServer>
    </configuration>
    Thread Starter sweettea2

    (@sweettea2)

    Scratch that…I thought I got it working, but then tried logging into the admin area of the WP site and got a 404 error. So, it works on the front-end, but messes up the admin area and won’t let me see the dashboard if I go to example.com/blog/wp-admin. It takes me to the login page if I go to example.com/blog/wp-login.php directly, but if I log in, it goes to a 404.

    Thoughts…??

    Moderator Marius L. J.

    (@clorith)

    Could you add an ignore part t oyour rule for the wp-admin directory and see if that helps ?

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Trailing Slash Problem’ is closed to new replies.