我正在尝试重写一个网址,例如:
example.com/var?id=0&blah=foo
以
example.com/?test=var&id=0&blah=foo
AddHandler application/x-httpd-php5s .php
RewriteEngine on
RewriteRule ^([A-Za-z0-9-]+)/?$ ?api_call=$1 [L,QSA]
将var
重写为?test=var
,但剩下的获取变量将被取消。
答案 0 :(得分:1)
尝试此规则:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([A-Za-z0-9-]+)/?$ ?api_call=$1 [L,QSA]