mod_rewrite with multiple variables

2019-09-04 04:31发布

I have a URL like so:

http://localhost/deals/?search=fred that redirects to index.cfm?path=

When I use mod rewrite the URL parameter becomes

path = /deals/?search=fred

I currently have RewriteRule /(.*) /index.cfm?path=/$1 [L]

How can I split it so I can actually use the URL variable "search"?

I am using IIRF rewrite.

2条回答
我命由我不由天
2楼-- · 2019-09-04 05:14

This fixed my problem.

thanks

RewriteCond %{QUERY_STRING} ^$
RewriteRule ^/(.*)$ /index.cfm?path=$1 [L]
RewriteRule ^/(.*)\?(.*)$ /index.cfm?path=$1&$2 [L]
查看更多
SAY GOODBYE
3楼-- · 2019-09-04 05:19
RewriteRule ^/(.*)/(.*)$ /index.cfm?path=$1&search=$2 [L]

However if you just wanna continue with what you use then you can simply use

RewriteRule ^/(.*)[?](.*)$ /index.cfm?path=$1?$2 [L]

OR it should be there by itself in the get variables and u can access it by something like

search = GET["search"]
查看更多
登录 后发表回答