在一个简单的 PHP 站点上使用了以下重写规则 .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /test/
RewriteRule ^index\.php$ - [L]
RewriteRule ^([a-zA-Z-]+)/?$ /test/index.php?m=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /test/index.php [L]
</IfModule>
以下 URL 正常工作:
domain.com/test/index.php?m=profile
domain.com/test/profile
domain.com/test/profile/
但是,重写会丢失其他查询参数:
domain.com/test/index.php?m=profile&id=2000 ==> works
domain.com/test/profile?id=2000 ==> does not work
domain.com/test/profile?id=2000 ==> does not work
任何帮助表示赞赏。