Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Error with folder redirect



3:35 pm on Jan 13, 2010 (gmt 0)

5+ Year Member

Happy New Year Friends!

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 On

RedirectMatch 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


while the pages for the /estate-agent/ folder are redirecting without any trouble

Kindly advise where I am going wrong with my redirect directives.



5:45 pm on Jan 13, 2010 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

You are mixing RedirectMatch directives from mod_alias with RewriteRule directives from mod_rewrite. The problem you're seeing is caused by the mod_rewrite code executing first and rewriting the static URL-path request to a dynamic filepath, followed by the RedirectMatch directives invoking an external redirect and thus 'exposing' the internal filepath as a URL to the client.

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.



Featured Threads

Hot Threads This Week

Hot Threads This Month