Apache Rewrite Rules breaking each other?
- by neezer
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.