Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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!

share|improve this question
add comment

1 Answer 1

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]
share|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
add comment

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.