简体   繁体   中英

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

<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:

 Request exceeded the limit of 10 internal redirects due to probable configuration error.

please add this code, it redirects the user paramater to url.

<IfModule mod_rewrite.c>
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^profile/([^/]+)?$ profile.php?user=$1 [L,QSA]

</IfModule>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM