Forum Moderators: phranque
I am trying to redirect all the content of a specific folder to the homepage.
While some URLs are redirecting in a proper way but some are encountering an error.
The content of my .HTACCESS is as follows:
Options +FollowSymlinks
RewriteEngine OnRedirectMatch 301 ^/d/(.*)$ http://www.example.com/
RedirectMatch 301 ^/estate-agent/(.*)$ http://www.example.com/RewriteCond %{QUERY_STRING} ^(sid¦action¦usg¦action¦id)=
RewriteRule $ http://www.example.com/? [R=301,L]
While URLs such as www.example.com/d/?action=displaycat&catid=118 are working properly but for some URLs such as www.example.com/d/Recreation/Games, the redirected URL becomes
http://www.example.com/?rewritten=1&action=displaycat&catname=Recreation/Games
while the pages for the /estate-agent/ folder are redirecting without any trouble
Kindly advise where I am going wrong with my redirect directives.
Thanks!
The best solution is to re-code your RedirectMatch directives as RewriteRules, placing all external redirects before all internal rewrites, and ending each rule with an [L] flag.
Jim