Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
    
What happens if you rename the index.php to index.bak in the WordPress root folder? Is the directory still not accessible? –  Horttcore Jun 16 '11 at 8:44
    
Have you tried to redefine the base url in your sub-folder .htaccess (with this sub-folder for value) ? –  Cédric G Aug 5 '11 at 15:19

7 Answers 7

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.

share|improve this answer
    
This is the correct answer! Thank you! –  Virgil Shelton Jun 11 '12 at 20:52
    
3. did the trick for me. Thank you @VirgilShelton ! –  rwzdoorn Jul 21 at 14:58

This has worked for me in the past for a similar situation :

Put this on top of .htaccess

ErrorDocument 401 default
share|improve this answer
    
Thanks! I've tried so many things, but this is the only solution that worked for my case: password-protected subdirectory –  Rado Mar 6 '13 at 23:27
    
Worked for me too, any explanation as to what it does and why it works? –  Asaf Aug 10 '13 at 8:27
    
Worked for me too! –  Tim S. Sep 6 '13 at 9:38

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.

share|improve this answer

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. I recommend hostmonster.com for cheap hosting that has great support and offers SSH access. I use them, costs about $5 per month. If you need something that is more robust and scalable, but still has good pricing then I recommend mediatemple.net. They offer scalable cloud hosting starting at $20 per month. Though I would only go with the second option if you expect to see dramatic increases in traffic or you already have very high traffic (I am talking 500-1,000+ per hour).

share|improve this answer

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
share|improve this answer
    
Hi @lizette. Welcome to WPSE forums. You may want to check out how formatting works here. –  Pothi Sep 21 '12 at 2:59

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?

share|improve this answer

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!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.