删除所有 .php 扩展名后的 htaccess 无法重定向单个文件
htaccess after removing all .php extensions can't redirect single files
我想使用 htaccess 从 URL 中删除所有 .php 扩展名,但也将例如 example.com/profile.php?user=test
重定向到 example.com/profile/test
以下代码将删除所有 .php 扩展名,但由于单个文件 (profile.php) 重定向
而出现 500 错误
<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= [QSA,L]
</IfModule>
apache2 日志:
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= [L,QSA]
</IfModule>
我想使用 htaccess 从 URL 中删除所有 .php 扩展名,但也将例如 example.com/profile.php?user=test
重定向到 example.com/profile/test
以下代码将删除所有 .php 扩展名,但由于单个文件 (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= [QSA,L]
</IfModule>
apache2 日志:
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= [L,QSA]
</IfModule>