Cannot access non-wordpress subdirectories as wordpress overrides them with a 404 error

I refer to this question previously asked and not suitably answered:
Wordpress overriding actual subdirectories
and also
Non “WordPress” pages/code getting 404 error

I have the same problem and I have tried nearly everything I found on the net. It’s definitely related to having permalinks turned on in the wordpress.
However, I have put a new .htaccess file in the subdirectory with:

RewriteEngine off

and the problem still exists. Even if I completely delete the wordpress .htaccess file the problem still exists.

I have also tried some other suggested solutions such as
ErrorDocument 401 “Unauthorized access”
ErrorDocument 404 “Unauthorized access”
Redirect 301 /mysubdirectory
in various locations all to no avail.

Can someone please offer another solution?
The only way I can fix it is to turn permalinks off but we need them to be on.




I’m assuming that you put WordPress in your site root and the external directories are also in your site root. The reason this is happening is that .htaccess files follow a hierarchy. Whatever directives are in the top-level .htaccess file flow down and apply to all directories below it.

If this is the case, you can do one of several things:

  1. Move your WordPress into its own directory.
    If you move WordPress into its own directory so that it is on the same level in your server directory hierarchy as the other directories the WordPress rewrite rules cannot affect the other directories.

  2. RewriteEngine Off – this would normally work. If it isn’t working check that you are not using a wildcard DNS setting. If you have a wildcard * hostname record pointing at your web server in your DNS settings it can cause havoc with .htaccess and subdomains.

  3. In the .htaccess file in your site root, add the following ABOVE the WordPress .htaccess directives:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_URI} ^/subdirectoryname1/(.*)$ [OR]
    RewriteCond %{REQUEST_URI} ^/subdirectoryname2/(.*)$ [OR]
    RewriteRule ^.*$ - [L]

One of these should work for you.

Leave a Comment