我有这样一个URL
abc.com/my-data/customer.php?id=2
我想把这个URL转换成
abc.com/my-data/?customer=&id=2
有什么办法吗?
发布于 2014-12-03 09:35:58
尝试:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^id=([0-9]+)
RewriteRule ^my-data/customer\.php$ /my-data/?customer=&id=%1 [L]发布于 2014-12-03 10:33:49
要转换该URL,您需要以下代码:
RewriteEngine On
RewriteBase /
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} \s/+(my-data)/customer.php\?id=(\d+) [NC]
RewriteRule ^ /%1/%2? [R=302,L,NE]
# internal forward from pretty URL to actual one
RewriteRule ^(my-data)/(\d+)/?$ $1/customer.php?id=$1 [L,QSA,NC]https://stackoverflow.com/questions/27267026
复制相似问题