I'm looking for the rewrite rule for mod_rewrite in Apache so that when asking for a specific subdirectory, it and all its contents gets redirected to another location.

I currently have the following:

    RewriteEngine  on
    RewriteRule    ^/SUBDIRECTORY(/.*)?  /another/location

But this only manages to redirect /SUBDIRECTORY requests to the desired location, while all others (like (/SUBDIRECTORY/ , /SUBDIRECTORY/anything/else ) gets me an error telling me that the redirection is not valid... The error is

Error 310 (net::ERR_TOO_MANY_REDIRECTS)

as if the redirections loops themselves...

any ideas?

Thanks!

link|improve this question

feedback

1 Answer

up vote 1 down vote accepted

Maybe try it without the question mark?

RewriteRule ^/somepath(.*) /another/location

Edit: I wonder if its just hitting some sort of loop, maybe try external redirection

RewriteRule    ^/SUBDIRECTORY(/.*)  /another/location [R]
link|improve this answer
nope... this throws me the same error as before... BTW I'm using Apache 2.2, and if I add a RewriteLog it doesn't writes anything to it :/ neither to error_log ... The error is a 310 Error (to many redirections) – Javier Novoa C. Jan 12 '11 at 19:29
that's it! the R flag fixed the problem... Thanks! – Javier Novoa C. Jan 12 '11 at 23:03
feedback

Your Answer

 
or
required, but never shown

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