我想要更改网址 http://example.com/index.php?city=newyork&cat=apple&q=ipad 至 http://example.com/newyork?cat=apple&q=ipad
请帮帮我。
我有.htaccess
DirectoryIndex index.php
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule ^/([a-z]+)(?:$|\?(?:.+)) /index.php?city=$1 [NC,L,B,QSA,NE]
但它不起作用
答案 0 :(得分:3)
尝试此规则:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)/?$ /index.php?city=$1 [L,QSA]
答案 1 :(得分:0)
RewriteCond %{QUERY_STRING} ^city=([^&]*)&(.*)$
RewriteRule ^index\.php$ /%1?%2