我有这样的网址
abc.com/my-data/customer.php?id=2
我想将该网址转换为
abc.com/my-data/?customer=&id=2
有什么办法吗?
答案 0 :(得分:2)
尝试:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^id=([0-9]+)
RewriteRule ^my-data/customer\.php$ /my-data/?customer=&id=%1 [L]
答案 1 :(得分:1)
要转换该网址,您需要以下代码:
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]