[英]htaccess after removing all .php extensions can't redirect single files
I want to remove all .php extensions from URL with htaccess but also redirect for example the example.com/profile.php?user=test
to example.com/profile/test
the following code will remove all .php extensions, but getting 500 error because of the single file (profile.php) redirection我想使用 htaccess 从 URL 中删除所有 .php 扩展名,但也将
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>
apache2 log:阿帕奇2日志:
Request exceeded the limit of 10 internal redirects due to probable configuration error.
please add this code, it redirects the user paramater to url.请添加此代码,它将用户参数重定向到 url。
<IfModule mod_rewrite.c>
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^profile/([^/]+)?$ profile.php?user=$1 [L,QSA]
</IfModule>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.