homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

htaccess in subdirectory

 1:14 pm on Apr 18, 2011 (gmt 0)

I have a wordpress install in my root folder, with the associated htaccess file, including a 404 redirect.

I have a subdirectory, non wordpress (different app) that needs it's own htaccess, with it's own 404 redirect.

It seems the htaccess in the root folder is taking precedence over the htaccess in the subdirectory. When I request a file that's 404 in the subdirectory, I get the wordpress 404. How can I change this behavior, so that the subdirectory htaccess takes precedence over the root htaccess, for files in the subdirectory?

here's the htaccess from the subdirectory:
ErrorDocument 404 /articles/images/404.php

So if I visit example.com /articles/images/doesnt-exist.jpg , I should get 404.php. I don't - I get the wordpress 404 from example.com



 6:55 pm on Apr 18, 2011 (gmt 0)

Found the solution on a drupal info site. Added the following lines to the root .htaccess, immediately after the RewriteEngine On line:
//ignore the articles directory so that 404 can get through
RewriteCond %{REQUEST_URI} "/articles/images/"
RewriteRule (.*) $1 [L]


 7:27 pm on Apr 18, 2011 (gmt 0)

Actually, now I'm not sure it is working, perhaps it's just ignoring the subdirectoy htaccess.


 7:30 pm on Apr 25, 2011 (gmt 0)

Horrid code!

Replace with one comment and one line of code:

# Skip all following rules for /articles/images/ path requests
RewriteRule ^articles/images/ - [L]

Note that this rule as coded here and above excludes only the /articles/images subdirectory (and everything in it and below it) The directory "/articles" itself and the pages/files in it are not excluded. Make sure that's what you intended.

Remember to delete your browser cache before testing any new server-side code.

Warning: There is no such thing as a "404 redirect." It is either more-accurately termed a 404-error document rewrite, or you have a potentially-fatal error lurking in your ErrorDocument directives. Be very sure that your ErrorDocument directives refer to filepaths, and not to URLs. Getting this wrong is the simplest way to cripple a site in the search results.


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved