Zamblek
Zamblek

Reputation: 809

How to escape “?” using regex in .htaccess for mod_rewrite

What is wrong in this rule?

RewriteRule ^page\?v=([^/]+)$ page.php?v=$1 [L,NC]

I just want to make the URL looks like that

http://www.domainname.com/page?sk=info

Upvotes: 2

Views: 994

Answers (2)

Romi Halasz
Romi Halasz

Reputation: 2009

Also, you can find additional information about this mod_rewrite case here: http://wiki.apache.org/httpd/RewriteFlags/QSA

And another SO entry about this issue here.

Upvotes: 0

Tom van der Woerdt
Tom van der Woerdt

Reputation: 29985

You don't have to include the query parts if they're not changing anyway.

RewriteRule ^page$ page.php [L,NC]

The RewriteRule will not match any part of the query string. page?v=123 will still become page.php?v=123

Also, your RewriteRule uses ?v= while you talk about ?sk=info

Upvotes: 2

Related Questions