开发者

Apache rewrite rule with parameters?

开发者 https://www.devze.com 2022-12-08 08:20 出处:网络
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:

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?


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]


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]


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号