Rewrite GET Query String using .htaccess

久未见 提交于 2019-12-20 03:03:40

问题


I want to Rewrite my GET Query String from this -

http://www.example.com/verify.php?key=547b52f2b5d20d258e62de1e27b55c

to this

http://www.example.com/verify/547b52f2b5d20d258e62de1e27b55c

I am using the following rule but it does not seem to work -

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(([A-Za-z0-9\-]+/)*[A-Za-z0-9\-]+)?$ $1.php

RewriteRule    ^[A-Za-z-]+/([A-Za-z0-9-]+)/?$    verify.php?key=$1    [NC,L]

回答1:


Use the following:

RewriteEngine On
RewriteCond %{THE_REQUEST} ^GET\ /verify\.php\?key=([^\s&]+) [NC]
RewriteRule ^verify\.php$ /verify/%1? [R=301,L]

RewriteRule ^verify/([^/]+)/?$ /verify.php?key=$1 [NC,L]


来源:https://stackoverflow.com/questions/34013698/rewrite-get-query-string-using-htaccess

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