我是htaccess mod_rewrite规则的新手。我想从URL中消除GET变量。我尝试过以下规则:
RewriteEngine On
RewriteCond %{THE_REQUEST} \?[^\ ]+
RewriteRule (.*) /$1? [R=301,L] #remove query string
上述规则取消了查询?id
,但它将网址重定向为www.example.com/admin/test.php
,没有子目录project
和扩展名.php
我想转换
www.example.com/project/admin/test.php?id=1
到
www.example.com/project/admin/test
答案 0 :(得分:0)
浏览 www.example.com/project/admin/test?id=1 与 www.example.com/project/admin/test.php?id=相同1 强>
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) $1.php