homepage Welcome to WebmasterWorld Guest from 54.197.15.196
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Error with folder redirect
pro_seo

5+ Year Member



 
Msg#: 4059919 posted 3:35 pm on Jan 13, 2010 (gmt 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!

 

jdMorgan

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



 
Msg#: 4059919 posted 5:45 pm on Jan 13, 2010 (gmt 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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved