views:

136

answers:

2
Redirect 301 /resort.php/FOO/BAR http://www.sitename.com.com/index.php
RewriteRule ^/direct/(.*) /direct/$1 [QSA,L] # access non i18n files directly
RewriteRule ^/([a-z]{2}\/.*)        /$1 [QSA,L] #any language subdirectory should be left alone
RewriteRule ^/(.*\/$)               /en/$1index.php [QSA,L] #fix for links ending in /
RewriteRule ^/(.*\.php)             /en/$1 [QSA,L]  #any php file with no language subdirectory redirects to the default language

What's the explanation for why the first Redirect 301 isn't going to the homepage? When I replace it with..

RewriteRule ^/resort.php(.*) http://www.sitename.com/index.php [R=301,L]

It starts working. I'm sure it's because I have a bunch of rules and it goes to one and jumps to the other but I'm kinda lost and maybe a guru could explain this more clearly.

My directory structure is like so:

/en/index.php
/direct/

There is no /index.php in the root, I'm redirecting it to en initially.

A: 
RewriteRule /resort.php/FOO/BAR http://www.sitename.com.com/index.php [R=P, L]

your rules arent jumping around, in fact, the L flag means LAST rule, so when one is triggered, the file stops being read.

Nona Urbiz
+3  A: 

The Redirect directive is getting into a bun-fight with mod_rewrite. The latter is quite aggressive, and is probably over-writing the redirect HTTP header set on the response by the Redirect directive.

You've already found the solution - use a RewriteRule to perform the redirect. The [L] flag means "last rule - don't process any more", which is how you prevent the rules from interfering with each other. The plain Redirect directive is just an easy way of achieving the simpler functionality of RewriteRule.

skaffman
ah, i knew it was some sort of conflict.
meder