我想从URL中删除所有。php扩展与htaccess,但也重定向,例如example.com/profile.php?user=test
到example.com/profile/test
以下代码将删除所有。php扩展,但得到500错误因为单文件(profile.php)重定向
<IfModule mod_rewrite.c>
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME}.php -f [NC]
RewriteRule ^ %{REQUEST_URI}.php [L]
RewriteRule ^(.*)$ profile.php?user=$1 [QSA,L]
</IfModule>
输入日志:
Request exceeded the limit of 10 internal redirects due to probable configuration error.
请添加此代码,它将用户参数重定向到url。
<IfModule mod_rewrite.c>
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^profile/([^/]+)?$ profile.php?user=$1 [L,QSA]
</IfModule>