Lizard
Lizard

Reputation: 44992

Modrewrite regex

I have the following URL: http://www.domain.com/keyword/b21?f=&ca1=50&p=1

And the RewriteRule I am trying to use is as follows:

RewriteRule ^([^.]+)/b([0-9]+)?f=([^.]+)&p=([0-9]+)$ script.php?id=$2&p=$2&filters=$3

Unfortunately this rule is not matching the URL.

I think it has something to do with the ? as i know this is a character used in regualr expressions.

Any help would be greatly apprecriated.

Upvotes: 0

Views: 55

Answers (2)

Alex Barrett
Alex Barrett

Reputation: 16455

I've not tested this, and I've not used a rewrite like this before myself, so it might not be exactly right.

RewriteCond %{QUERY_STRING} ^f=([^.]+)&p=([0-9]+)$
RewriteRule ^([^.]+)/b([0-9]+)$ script.php?id=$2&p=$2&filters=%1

Upvotes: 2

Matteo Riva
Matteo Riva

Reputation: 25060

I strongly suggest you redirect the URL with the full query string and process it directly in the PHP script with parse_str()

Upvotes: 1

Related Questions