Why sometimes RewriteRules don’t work
Posted: November 10th, 2009 | Author: paul | Filed under: howto, linux | Tags: apache, mod_rewrite | No Comments »I’m not an expert, but here is what you should check.
When you add a domain to be forwarded to a page on the same domain like this:
RewriteCond %{HTTP_HOST} domain-1.tld
RewriteRule ^/$ http://www.domain-1.tld/link/to/the/page/you/want/to/be/forwarded.htm [L]
And, after this you want another section named “section”of this site to be forwarded elsewhere, the other domain like this:
RewriteCond %{HTTP_HOST} domain-1.tld
RewriteRule ^/section$ http://www.domain-2.tld/link/to/a/section.htm
This will not work.
This will not work even if you want to escape the /section by placing it above the rewriterule for /.
This is happening because of the [L] from the first rewrite.
[L] Tells Apache to not process any more RewriteRules if this one was successful.
Now add [L] for /section and you are good to go.
Leave a Reply