Forum Moderators: phranque

Message Too Old, No Replies

.htaccess redirect directory

but not subdirectories

         

bubster1199

8:56 am on Mar 14, 2007 (gmt 0)

10+ Year Member



Hi, does anyone have any smart ideas on how to stop a subdirectory from redirecting?

Heres what i'm trying to achieve: i've got a client folder on my server which I want to redirect to the domain root- which i've sorted with "Redirect /client [yoursite.com...] and it works fine, apart from the fact that the subfolders of the client have inherited the redirect function. So if the user browses to www.yoursite.com/client/client01/index.htm htaccess redirects them to www.yoursite.com/client01/index.htm but I don't want to redirect the subfolders contained within the "client" folder.

So do I just need to amend the htaccess file in the client folder to include "Redirect /client [yoursite.com...] to redirect traffic to the same path or is there a tidier way to do it- like a stop redirect function or something.

Thanks in advance for any help.

jdMorgan

3:36 pm on Mar 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Instead of trying to use mod_alias directives, use mod_rewrite [httpd.apache.org], which supports conditional redirects and rewrites through the use of the RewriteCond directive, checking parts of the client request info such as REQUEST_URI and HTTP_HOST.

Jim

[edited by: jdMorgan at 3:37 pm (utc) on Mar. 14, 2007]

bubster1199

3:56 pm on Mar 14, 2007 (gmt 0)

10+ Year Member



Thanks Jim, I'll look into that.

As you can probably tell I'm new to this :) in fact in all naivety I hadn't expected it to be so complicated to simply redirect one folder and NOT the subfolders contained within it.

Oh well, C'est la vie!