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:

Read More

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”
and
ErrorDocument 404 “Unauthorized access”
and
Redirect 301 /mysubdirectory http://www.mydomain.com/mysubdirectory/index.html
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.

Thanks,

Nicole

Related posts

Leave a Reply

8 comments

  1. 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.
      See: http://codex.wordpress.org/Moving_WordPress
      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]
      </IfModule>
      

    One of these should work for you.

  2. when i copy my files into the same server but with different subdirectory folder so when i tried to access my pages, index.php is working fine but the other pages are not and giving me a 404 error. Sorry for my bad english!!

    I just look into my htaccess the original:

    # BEGIN WordPress
    
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    
    # END WordPress

    and put the new one with

    # BEGIN WordPress
    
    RewriteEngine On
    RewriteBase /subdirectoryfolder
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /subdirectoryfolder/index.php [L]
    
    # END WordPress
    
  3. I see this thread is a few months old, but just in case you never got it to work!

    I had a similar issue, but my problem was that the wordpress install was located in the subdirectory which prevented URL access to folders within the root (outside the WP install directory), but only when permalinks were enabled. To solve this, I copied both index.php and .htaccess (copy not move) from the subdirectory where the WP install is located and placed them both in the root public_html (or whatever subdirectory that you’re trying to access outside the WP install directory). The .htaccess file has the rewrite conditions for permalinks already:

    RewriteEngine On
    RewriteBase /subdirectoryinstallfolder/
    RewriteRule ^index.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    

    Enable permalinks for refresh and it solved all issues. Make sure your permissions for the root folders are set correctly too as this has caused me problems in the past.

  4. If you are still getting 404’s with the htaccess disabled and you have verified the paths and you know the files are there then your only options left are these three…

    Options…

    1. Server is quite possibly running a case-sensitive operating system. Which means if you are typing in a path and not using the exact characters and casing it simply will not work.
    2. Permissions: You may have the wrong permissions on the file or folder or a parent folder. Try to change the permissions to 755 on the files, folders, and parent folders. If you have ssh (terminal) access to it then go to your root and run this “chmod -R 755 mydir” and that will recursively set the permissions for all of them.
    3. If you are still having a problem after all of that then you have a server config problem (Apache probably). You will need to talk to your hosting provider about it.

    If none of that works then you need a new host.

  5. After nearly plucking my hair editing the htaccess I finally found a solution that will work for WordPress.

    I had this problem after installing a codeiginter script on the same root directory that WordPress is installed.

    After trying all the tricks listed here I was still getting 404 errors on the pages associated with the new script.

    I noted that the WordPress htaccess was overiding the script’s htaccess. I also noted that other WordPress installations in the same directory did not have this 404 error.

    I simply adopted the htaccess from the new WordPress installation in the same server directory and added it in the folder where my script is located. Here is how it looks like :

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

    Replace subdirectoryname with the name of your directory and place this htaccess file inside the folder where your script is located.

    Example : If the site is installed here

    public_html/

    and the new folder is located

    `public_html/example`
    

    copy the htaccess above and save it inside the folder ‘example’ and this should work.

  6. I’ve looked at the responses here a number of times as I’d run into a similar problem. I have files in a subdirectory that would throw a 404 error when I tried to access them. All the .htaccess stuff failed to rectify it, as Kirsten Douglas says, WordPress does the job already.

    My solution

    I found this article after checking the error_log on the server. I was getting a message about wrong uid for scripts. I also noticed that the 404 wasn’t being thrown because of the file, but because the server couldn’t serve up a 500.html file i.e. I had a 500 error.

    Turns out I’d created files as root, and needed to change ownership to the webfiles owner.

    I hope this helps others who’ve had the same issue!

  7. You should be able to just add a RewriteCond directive that will make sure the WordPress rules are ignored for requests inside your subfolder.

    RewriteCond %{REQUEST_URI} !^/mysubdirectory
    # rest of WordPress rewrite rules
    

    However, you say that even with no WordPress .htaccess you’re experiencing the problem? What’s the contents of your subdirectory .htaccess?