Welcome to WebmasterWorld Guest from 54.159.250.110

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

htaccess in subdirectory

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

WebmasterWorld Senior Member wheel is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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)

WebmasterWorld Senior Member wheel is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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)

WebmasterWorld Senior Member wheel is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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.

Jim