homepage Welcome to WebmasterWorld Guest from
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

301 Redirect for removed dynamic page

 6:05 am on Sep 28, 2006 (gmt 0)

Hi JD;

I have been reading / testing / pulling hair for hours and cannot get this simple thing to work...

We've taken over an old site that had an affiliate program. Google Sitemaps is telling us there have been several 404s to www.oursite.com/default.asp?AffID=#### (default.asp does not exist any more)- I would like to redirect these to www.oursite.com/newaffiliate-signup/

I've tried everything and can almost get it to work, but usually get the?AffID=### appended to the new url.

This was the closest thing I could find that resembled our situation, but it does not work at all:
RewriteRule ^default.asp?AffID=(.*)$ /newaffiliate-signup/ [L,R=301]

What am I doing wrong?

Thanks in advance.



 6:13 am on Sep 28, 2006 (gmt 0)

You need to check for the query string separately.

RewriteCond %{REQUEST_URI} ^/default.asp$
RewriteCond %{QUERY_STRING} ^(.*&)AffID=####(&.*)$
RewriteRule ^.*$ /newaffiliate-signup/ [L,R=301]

[edited by: DrDoc at 6:14 am (utc) on Sep. 28, 2006]


 2:25 pm on Sep 28, 2006 (gmt 0)

Another way to do it would be:

RewriteCond %{QUERY_STRING} &?AffID=[^&]* [NC]
RewriteRule ^default\.asp$ http://www.example.com/newaffiliate-signup[b]/?[/b] [R=301,L]

You'll need the question mark at the end of the substitution URL to clear the current query string.

I'm not sure about redirecting to the aff signup page, though. You may end up redirecting visitors who follow an affiliate link to the signup page. If that's not what you want, just change the substitution URL.



 3:36 pm on Sep 28, 2006 (gmt 0)

Thanks Jim;

Worked like a charm. Also thanks for the heads up about affiliate links... I never thought of that.



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