mod_rewrite with multiple variables

拥有回忆 提交于 2020-01-17 07:42:28

问题


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.


回答1:


This fixed my problem.

thanks

RewriteCond %{QUERY_STRING} ^$
RewriteRule ^/(.*)$ /index.cfm?path=$1 [L]
RewriteRule ^/(.*)\?(.*)$ /index.cfm?path=$1&$2 [L]



回答2:


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"]


来源:https://stackoverflow.com/questions/6789944/mod-rewrite-with-multiple-variables

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!