Support » Fixing WordPress » Mod Rewrite Conflicting with other .htaccess files

  • Resolved vcardillo

    (@vcardillo)


    P.S. Before I begin, I did search all around for this problem, but neither found a solution nor found anyone describing my exact situation.

    Hello Everyone,

    I’m having a problem with mod rewrite that I’m not understanding. Here is my modrewrite code:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    My blog is located at http://www.vincecardillo.com . For whatever reason, if I hit my .com/images, I get the wordpress 404 page. This isn’t so bad. I’m pretty sure it has to do with the fact that I’ve used Options -Indexes. But, there is where the problem is:

    http://www.vincecardillo.com/blog/wp-content/plugins/postie/get_mail.php

    Notice the glaring 404 error. I assure you, that file exists. But the 404 error occurs when I try and password protect that directory using .htaccess, since I don’t want just anyone being able to ping that page. If I remove the .htaccess from the Postie directory, then I am able to reach get_mail.php just fine.

    Further, if I remove all of WordPress’s ModRewrite rules from the .htaccess in my root public_html folder, then all of these problems disappear. Which leads me to believe this issue stems from something with WP’s ModRewrite stuff.

    So I have several questions here:

    1. Why do WP’s rewrite rules produce WP’s 404 error page if I use a .htaccess anywhere else on the site?

    2. Why do WP’s rewrite rules produce WP’s 404 error page for files that actually exist?

    Thanks for any help in advance,
    – Vince

Viewing 14 replies - 1 through 14 (of 14 total)
  • Thread Starter vcardillo

    (@vcardillo)

    I simply don’t think there’s a way to solve this. I’ve looked all around. One promising post I found was here: http://forum.dreamhosters.com/troubleshooting/61235-.htaccess-Conflicts.htm

    It gives a detailed explanation of why conflicts occur with ModRewrite. But its solution failed.

    This was the response I got from my hosting provider:

    Sorry, but there is no way to use WordPress rewrite lines and Password protection for subdirectories.

    Isn’t there a way to tell the rewrite rule to ignore certain directories?

    Thread Starter vcardillo

    (@vcardillo)

    I figured it out. I hope this will help others.

    I had installed my WordPress to .com/blog. However I was placing the .htaccess file in my root directory. I thought this was fine since I wanted to show my blog both on my homepage and at .com/blog.

    Eitherway, moving the .htaccess rewrite file to the blog directory has solved the problem.

    My suggestion to people is to never install WordPress in your root public_html directory. It only mucks things up.

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Sorry, but there is no way to use WordPress rewrite lines and Password protection for subdirectories.

    False.

    Create a file on your website. Call it onerror.html. It can be empty or have just <html></html> in it for all that it matters.

    In WordPress’s .htaccess file, add this to the top of the file:

    ErrorDocument 401 /path/to/onerror.html
    ErrorDocument 403 /path/to/onerror.html

    Obviously, change the path to be correct and such.

    This will allow password protected subdirectories of the WordPress blog to work.

    The reason for this is explained in more detail here:
    http://wordpress.org/support/topic/89515

    Thread Starter vcardillo

    (@vcardillo)

    Interesting. I knew there had to be a way around it. I appreciate your link to the explanation! I’ve been trying to figure this out for days, because I wanted to password protect my Postie directory.

    Interesting stuff. I’ve recently moved a bunch of blogs from FreeBSD hosting to Linux hosting.

    Previously, I could password protect their admin directories and access them without problems. That’s also true on the new server (which, in addition to the switch to Linux, likely has updated versions of PHP and other software) — unless the WP blog is in the site root.

    I’ve found solutions that work *sometimes* but not always (I even posted one on one of my blogs, but it’s a “sometimes” solution). We’ll keep working on this until we find an answer, or determine that it just won’t work.

    I had to add ErrorDocument 404 to my.htacess file since my problem is returning a 404 error.

    I get this when trying to access a password protected directory.

    The page isn’t redirecting properly

    Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
    * This problem can sometimes be caused by disabling or refusing to accept
    cookies.

    What could be the problem?

    thats a loop, probably caused by you redirecting to something that doesnt exist..

    I’m trying to get to the admin in my oscommerce
    maybe I should post what I have in my htaccess?

    ErrorDocument 401 /home/username/public_html/onerror.html
    ErrorDocument 403 /home/username/public_html/onerror.html
    ErrorDocument 404 /home/username/public_html/onerror.html

    Options +Indexes
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond ${HTTP_HOST} .
    RewriteCond %{HTTP_HOST} !^domain\.com
    RewriteRule (.*) http://domain.com/$1 [L,R=301]

    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !(.*)/$
    RewriteRule (.*) http://domain.com/$1/ [L,R=301]

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    # END WordPress

    the simplest thing to do is check your error log available in cpanel

    I cant troubleshoot that with that information. Someone else might be able to, but I cant.

    loops caused by .htaccess typically stem from someone redirecting to a redirect to a redirect to a redirect, if that makes sense —

    Checked my log, and all of them either say that onerror.html doesn’t exists when in fact it does.

    The other error is client denied by server configuration for onerror.html

    dont use the path to the file that you have provided.. that path is relative to site root.

    ErrorDocument 401 /onerror.html
    ErrorDocument 403 /onerror.html
    ErrorDocument 404 /onerror.html

    Thanks, it worked! 🙂

    I think that I need to do something like this, but have not figured out exactly what. I tried the stops above without success. What I am trying to do is have a directory like this:

    /images/something.jpg

    I have the file uploaded, permissions right (even tried 777) but can’t access the image from the blog or like this:
    http://www.example.com/images/something.jpg

    Any suggestions?
    Thanks!

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Mod Rewrite Conflicting with other .htaccess files’ is closed to new replies.