Forum Moderators: phranque

Message Too Old, No Replies

Another rewrite question

mod_rewrite with question marks

         

robbrandt

6:18 am on Jul 27, 2012 (gmt 0)

10+ Year Member



I am migrating content from one system to another. There is little logical relationship between the old URLs and the new URLs, so I had planned on just targeting broad categories of content lists. No fancy regex, but there are question marks and ampersands involved. I am starting with published rss feed URLs. Here's a sample:


OLD
rss.php?categoryID=53

NEW
index.php?module=news&type=user&func=list&tid=1&filter=blogtopic:eq:19

I tried

RewriteRule ^rss.php\?categoryID=53 index.php\?module=news&type=user&func=list&tid=1&filter=blogtopic:eq:19 [L]

but it doesn't match. If I follow that one with

RewriteRule ^rss.php index.php?module=news&type=user&func=list&tid=1 [L]

if DOES match, so I conclude that the question mark in the old URL is causing the problem. I am already escaping the question mark. What do I do?

Thanks

g1smd

7:24 am on Jul 27, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Those examples have two parts:
- the path and file (the 'URL'), and
- the query string appended to the URL.

RewriteRule can see and match only the path and file part.

Detect the appended query string with a preceding RewriteCond looking at QUERY_STRING.

Escape literal periods in RegEx patterns.

Do not escape anything in the rule target.

Use example.com for all example URLs in this forum.