I have an .htaccess
file with the following rules
# replace 'RewriteBase' with current working folder
# put '<base href="/">' in <head> if you are in the root folder
# put '<base href="/foldername/">' in <head> if you are in a subfolder of the root
Options +FollowSymLinks
RewriteEngine On
RewriteBase /pretty-urls
# Remove slash if file
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ $1 [R=301,L]
# Redirect to extensionless url
RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.php$ $1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [L]
RewriteRule ^(.*)$ user.php?u=$1 [NC]
This basically transforms and redirects any of the following URLS, www.mysite.com/about.php
, www.mysite.com/about
and www.mysite.com/about/
to www.mysite.com/about
and also should allow me to write www.mysite.com/user/john
but instead throws a Internal Server Error plus a 500.
I can't figure out what is wrong, the code is based on this ( How-to? Vanity URL & ignore .PHP extension with .htaccess )
My php looks like this
foreach ( $users as $user ) {
echo '<p><a href="user/'.$user->username.'">'.$user->username.'</a></p>';
}
Any help is appreciated, thank you.
EDIT: the Apache error log says
[Fri Sep 27 14:26:26.539589 2013] [core:error] [pid 2276:tid 1680] [client ::1:60023] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://localhost/pretty-urls/users
As suggested, I removed the [NC]
flag and added the [L]
flag, but the same error persists.