mod rewrite rule for a url with multiple get variables

青春壹個敷衍的年華 提交于 2019-12-11 12:54:15

问题


Im new to url rewriting, Im able to build simple rules but unable to build a rule for a url consisting of multiple get variables

My url is: http://www.mywebsite.com/index.php?AKey=fjdsakfd&uid=2&cl=Election&req=Voters

I want a clean url like: http://www.mywebsite.com/voters

Kindly help me in building the correct rewrite rule for the above 'clean url'


回答1:


Put this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteRule ^voters/?$ /index.php?AKey=fjdsakfd&uid=2&cl=Election&req=Voters [L,QSA,NC]

EDIT: Based on comments:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/?$ /index.php?cl=$1&req=$2 [L,QSA]


来源:https://stackoverflow.com/questions/22435825/mod-rewrite-rule-for-a-url-with-multiple-get-variables

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