Welcome to WebmasterWorld Guest from 54.159.50.111

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Error with folder redirect

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

Junior Member

5+ Year Member

joined:Jan 11, 2007
posts: 97
votes: 0


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

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!

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

Senior Member

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

joined:Mar 31, 2002
posts:25430
votes: 0


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.

Jim