Apache Rewrite Rules breaking each other?
Posted
by neezer
on Server Fault
See other posts from Server Fault
or by neezer
Published on 2010-06-17T21:05:54Z
Indexed on
2010/06/17
21:13 UTC
Read the original article
Hit count: 296
apache
|mod-rewrite
I have this rule:
RewriteCond %{REQUEST_URI} ^/(manhattan|queens|westchester|new-jersey|bronx|brooklyn)-apartments/.*$
RewriteCond %{REQUEST_URI} !^/guide/(.*)$
RewriteRule ^(.*)$ /home/neezer/public-html/domain.com/guide/$1 [L]
Which works great on it's own. Essentially, I have a bunch of directories that have a bunch of files in them that I want to keep in the "/guide" folder, but I want them to appear at the web root for SEO reasons.
This rule works, but unfortunately the original URL's still work too (with "/guide"). I want to 301 Redirect the ones with "/guide" in the URL to those without, without actually moving the files on the server.
I tried adding this rule:
RewriteCond %{REQUEST_URI} ^/guide/(manhattan|queens|westchester|new-jersey|bronx|brooklyn)-apartments/.*$
RewriteRule ^guide/(.*)$ http://www.domain.com/$1 [R=301,L]
... but that breaks my first rule completely.
Any thoughts about what I might be doing wrong? Please let me know if you need to know anything else from me to help me with this issue.
© Server Fault or respective owner