我有一个使用php构建的小型网站,现在我想使用通常的get参数设置的结尾。例如:
class.php?id = 1&user = 2到class / id / 1 / user / 2
并只需删除任何“ .php”扩展名,以便访问index.php将更改为index /
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+(.+?)\.php[\s?] [NC]
RewriteRule ^ /%1/ [R=302,L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/(.*?)/(.*?)/?$ $1.php?$2=$3 [L]
它实际上适用于“ example.com/class/id/1/user/2”,但是当url为“ example.com/index/”时不起作用