Forum Moderators: phranque

Message Too Old, No Replies

Redirecting a url with a query string

or modifiying the query string variable...

         

cnewkirk

10:22 pm on Nov 15, 2007 (gmt 0)

10+ Year Member



I've been looking around for a fix for this for a few days now and haven't come across anything that works. There seems to be some crazy smart people in here, so I thought I'd try...

The Problem:
I was messing around with my CMS a few weeks ago and I added a new section that contains an RSS feed. I got it all working the way I wanted it and then changed the name of the section. But from the time I created the name, Google Feedfetcher found out about the RSS feed and now they are requesting it every 3 hours and getting a 404. I really want Google to fetch the new feed when they request the old one. (I hope this makes sense...)

The old broken link:
www.example.com/rss/?section=oldname

The one that works and I want people to use:
www.example.com/rss/?section=newname

I've played around with my .htaccess file but only resulted in generating "500 Internal Server" errors instead of the 404.

Any help is appreciated. thanks!

jdMorgan

2:06 am on Nov 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Please post your best-effort code for discussion.

Thanks,
Jim

cnewkirk

4:07 am on Nov 16, 2007 (gmt 0)

10+ Year Member



Sure. Like I said, I was playing around with it and tried a few things. This was the latest I tried (I started just overwriting the file after awhile):

RewriteCond %{QUERY_STRING} section=oldname
RewriteRule (.*)?section=newname [R=301, L]

jdMorgan

3:21 pm on Nov 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I assume this code is located in example.com/rss/.htaccess. If so, try:

RewriteCond %{QUERY_STRING} section=oldname
RewriteRule (.*) http://www.example.com/rss/$1?section=newname [R=301,L]

If located in example.com/.htaccess, try:

RewriteCond %{QUERY_STRING} section=oldname
RewriteRule ^(rss/.*) http://www.example.com/$1?section=newname [R=301,L]

If additional query string parameters are used and need to be retained, then we have a bit more work to do...

Jim

cnewkirk

3:36 pm on Nov 16, 2007 (gmt 0)

10+ Year Member



Example 2 did it. You are awesome! Thanks.