Support » Fixing WordPress » IIS Rewrite rule doesn't work if not logged in as admin

  • Resolved goingdev

    (@goingdev)


    I have my wordpress installed in a subfolder of my domain: http://mydomain.com/Blog.

    I have a rewrite rule set up which loads the wordpress pages without having “index.php” in the URL:

    <rewrite>
          <rules>
            <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"/>
            </rule>
          </rules>
        </rewrite>

    With this rewrite rule, my blog loads at http://mydomain.com/Blog, and there’s no need to use index.php like http://mydomain.com/Blog/index.php.

    The issue is that the above only works if I’m logged in to wp-admin, specifically, if the “wordpress-logged-in” cookie is there. Otherwise, http://mydomain.com/Blog returns a blank page (no error – HTTP response 200).

    I am totally baffled by this – why would a cookie have an effect on this?

    Can this be a bug? How do I go about fixing this?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Your rewrite rules shouldn’t be impacted by a cookie. My web config is slightly different than yours but it’s working fine whether logged in as admin or just as a website visitor that’s not logged in at all. Hopefully the below is the correct way to mark code… Only other thought is that the IIS rewrite module isn’t working properly on your install.

    <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>

    You can also try resetting the permalinks if you haven’t already done that….

    Thread Starter goingdev

    (@goingdev)

    I don’t think it’s really the rewrite rule as the http resonse is a 200 when navigating to /Blog. I think it’s the way wordpress is processing the request, and not loading the content.

    Your snippet doesn’t change anything.

    My rewrite module is working fine on my other sites on IIS, and it does work when I’m logged in….so it must be installed correctly.

    Thread Starter goingdev

    (@goingdev)

    Tried resetting permalinks, didn’t work.

    I had a similar problem when I was on Godaddy Windows hosting. They “upgraded” the server I was on and in doing so they took down every one of my sites because it was no longer processing the webconfig file properly as did the previous server. It was a 200 error. You aren’t on Godaddy, are you? =D

    Thread Starter goingdev

    (@goingdev)

    Nope, stand-alone IIS web server.

    See, it all works if I’m logged in as admin. That’s what make me think it’s wordpress / internal bug.

    If it would be something specific to my server/IIS, it wouldn’t work regardless if I’m logged in or not.

    Wait, 200 error? That’s like an oxymoron

    That’s just super weird… Ugh. Have you peeked in the log files at all? Rebooted (the magic-fix-all)? Many times just starting and stopping the WWW Publishing service doesn’t seem to clear things.

    I’ve had my own fair share of fun with IIS and PHP so I feel your pain. There don’t seem to be a lot of people who are running on Windows.

    You might want to give this a run-thru although it’s not very windows-centric http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory

    The one other thing that popped to mind was competing web config files

    Yeah, 200 ‘error’ being that there’s nothing to see here even though there should be, hahah.

    Not sure if you tried installing this in the root / on a different dev server to see if you have to same issues as on the one you’re having the fight with.

    Thread Starter goingdev

    (@goingdev)

    It’s working now. I didn’t touch IIS or the word press files.

    What I did do was disable some cache plugins: Autoptimize, WP Total Cache, WP Super Cache. I was also testing on a different server, and I played around with the site / blog address settings. I’m not sure what actually did it, and can’t imagine how it started working.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘IIS Rewrite rule doesn't work if not logged in as admin’ is closed to new replies.