19

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?

Kevin Worthington
  • 457
  • 2
  • 5
  • 17
James
  • 80,725
  • 18
  • 167
  • 237

3 Answers3

25

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]
clops
  • 5,085
  • 6
  • 39
  • 53
7

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]
Kepi
  • 332
  • 3
  • 10
0

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.

Jonas Czech
  • 12,018
  • 6
  • 44
  • 65
Tim Smith
  • 682
  • 8
  • 5