How would I go about re-directing a parent directory but not children? See my specific issue below. All and any help is appreciated!
Parent -
redirect 301 /community/whats-happening http://www.stapletondenver.com/whats-happening/
Child -
redirect 301 /community/whats-happening/celebrating-halloween-stapleton http://www.stapletondenver.com/whats-happening/celebrating-halloween-in-stapleton/
I have tried a handful of other options to no success. See below:
RewriteRule ^community/whats-happening/. /whats-happening/ [R=301,L]
RewriteRule ^community/whats-happening/(.*)$ /whats-happening/$1 [R=301,NC,L]
RewriteRule ^/?community/whats-happening/?$ http://www.stapletondenver.com/whats-happening/ [R=301]
RewriteRule ^community/whats-happening/(.*) http://stapletondenver.com/whats-happening/$1 [R=301,L]
RewriteRule ^community/whats-happening/(.*)/(.*)/? http://stapletondenver.com/whats-happening/$1/ [R=301,L]
This is happening because of your first redirect. The Redirect
directive redirects all subdirectories and files to, so:
Redirect 301 /abcd http://domain.com/xyz
means
/abcd/
-> http://domain.com/xyz/
/abcd/1234/
-> http://domain.com/xyz/1234/
/abcd/1234/z.html
-> http://domain.com/xyz/1234/z.html
etc.
If you only want the parent directory to redirect, use a regex and RedirectMatch
with a $
end character:
RedirectMatch 301 ^/community/whats-happening/?$ http://www.stapletondenver.com/whats-happening/
RedirectMatch 301 ^/community/whats-happening/celebrating-halloween-stapleton/?$ http://www.stapletondenver.com/whats-happening/celebrating-halloween-in-stapleton/