James
James

Reputation: 82096

Apache rewrite rule with parameters?

I have the following URL:

http://domain.com/index.php?m=feedback&cSubject=My Subject

I want to have a rewrite rule so that the following:

http://domain.com/feedback?Subject=My Subject

maps to the previous url. Heres my rule at the moment:

RewriteRule ^feedback?Subject=(.*)$ index.php?m=feedback&cSubject=$1

Doesn't seem to be working tho! Any ideas?

Upvotes: 19

Views: 41426

Answers (3)

Tim Smith
Tim Smith

Reputation: 682

There seems to be an = missing from clops answer to give..

RewriteRule ^feedback/?$ index.php?m=feedback&c=%{QUERY_STRING} [NC,L]

.. at least I need one to make it work.

Upvotes: 0

Kepi
Kepi

Reputation: 351

You can use RewriteCond statement to do exactly what you want:

RewriteEngine On

RewriteCond %{QUERY_STRING} Subject=(.*)
RewriteRule ^feedback$ index.php?m=feedback&cSubject=%1 [L]

Upvotes: 7

clops
clops

Reputation: 5235

Query Strings are not parsed by Apache Mod_Rewrite, but there is a workaround. Try this

RewriteRule ^feedback/?$ index.php?m=feedback&c%{QUERY_STRING} [NC,L]

Upvotes: 25

Related Questions