Forum Moderators: phranque

Message Too Old, No Replies

RedirectMatch and escaped characters

trailing URL fragment missing

         

dhiggerdhigger

12:26 pm on Nov 10, 2007 (gmt 0)

10+ Year Member



I'm trying to send vistors permanently from
www.example.com/forum/rss/?c=8
to
www.example.com/forum/syndication.php?type=atom&t=1

I've tried using, in .htaccess
RedirectMatch ^/forum/rss/ http://www.example.com/forum/syndication.php?type=atom&t=1 [L,R=301]
and
RedirectMatch ^/forum/rss/ http://www.example.com/forum/syndication.php\?type=atom&t=1 [L,R=301]

but both redirect only to
www.example.com/forum/syndication.php
and not to
www.example.com/forum/syndication.php?type=atom&t=1

How can I get the rest of the URL after the "?"?

Thanks for any help.

jdMorgan

2:37 pm on Nov 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



mod_alias directives such as Redirect and RedirectMatch do not recognize query strings attached to URLs. You'll need to use mod_rewrite, and additionally, use a RewriteCond to test for the desired query string.

Jim

dhiggerdhigger

6:25 pm on Nov 10, 2007 (gmt 0)

10+ Year Member



Thanks Jim.

Here's what worked:


RewriteEngine on
Options +FollowSymLinks
RewriteRule ^forum/rss(.*)$ http://www.example.com/forum/syndication.php?type=atom&t=1 [R=301,L]

Seems a RewriteCond wasn't needed.

Dave

jdMorgan

9:12 pm on Nov 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You'd need the RewriteCond if you wanted to invoke the rule only when the "c=8" query was present, as stated in your original post.

Jim

dhiggerdhigger

9:09 am on Nov 11, 2007 (gmt 0)

10+ Year Member



Yes I wasn't very precise in my first post. Although most of my site's users would be using the?c=8 query, some may not, but anyway I just wanted to redirect them all.

Good to know about the RewriteCond for the future.

Thanks again.