• I have a wordpress install that I host myself and I need some help with htaccess.

    I am using one of the suggested htaccess files for better security. By default, it works fine. I now have a few non-wordpress pages (php and html) that I need to host in a subdirectory that will not work with my current rewrite rules. I have traced it down to one specific rule, but I do not know enough about rewrite to fix it. Here are the details:

    / (http root)
    – .htaccess
    – wp root
    – subdir1
    – index.php (works)
    – page.html (works)
    – subdir2
    – index.php (does not work)
    – page.html (does not work)

    The rewrite rule that makes the pages in the 2nd subdirectory fail is:

    RewriteRule . /index.php [L]

    The failure I get is page cannot be found in wordpress. Like I said, these pages are not connected to wordpress in any way. They’re standalone pages for a specific need. Anyone know rewrite that can tell me how to fix this?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Pete Moore

    (@techmystressaway)

    Does the 2nd sub directory have a .htaccess file in it?

    It sounds like that directory has a .htaccess file in it with the WordPress rewrite rule

    Pete

    Thread Starter djtech2k

    (@djtech2k)

    The 2nd subdir does have an htaccess, but it only has stuff in it to password protect the directory. So it has:

    AuthType Basic
    AuthName “report”
    AuthUserFile “/path/to/passwordfile”
    require valid-user

    Pete Moore

    (@techmystressaway)

    It’s strange that sub 1 works but sub 2 doesn’t.

    Is WP installed in the root or as a sub directory that wasn’t clear to me

    Thread Starter djtech2k

    (@djtech2k)

    I find it strange also.

    WP is installed in the website root, no subdir.

    The files/pages in the subdir and sub-subdir are standalone php and html.

    Thread Starter djtech2k

    (@djtech2k)

    Any ideas anyone?

    Pete Moore

    (@techmystressaway)

    Try adding this line to the .htaccess in the root:

    ErrorDocument 401 default

    I think it might be to do with the fact you’re password protecting that 2nd sub dir

    So you’re not getting the login box pop up

    Worth a shot

    Pete

    Thread Starter djtech2k

    (@djtech2k)

    Ok I added it and tested. The page now seems to load. Here is the content of my htaccess at the root level. Again, this was made to help secure wp just a little more. Does that ErrorDocument override the rewrite stuff that locks it down a little bit? Just trying to understand better what it is doing.

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    ErrorDocument 401 Default
    # END WordPress

    Pete Moore

    (@techmystressaway)

    Put the ErrorDocument 401 Default before the # BEGIN WordPress line.

    By password protecting the directory you’re creating a 401 response saying authentication is required.

    So by putting the error handler from what I understand you’re essentially saying Oi WordPress stop messing with my 401’s ??

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Help With htaccess RewriteRule’ is closed to new replies.