Forum Moderators: phranque
# first remove the .php
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
# then redirect shtml to no-extension
RewriteRule ^(.+)\.shtml$ $1 [L,NC,R=301] RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
# force redirect of shtml to no-extension
RewriteCond %{THE_REQUEST} ^GET\s.+\.shtml
RewriteRule ^(([^/]+/)*[^/.]+)\.shtml$ http://www.example.com/$1 [R=301,L]
# non-www to www
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteRule ^(([^/]+/)*[^/.]+) http://www.example.com/$1 [R=301,L]
# parse file as file.php
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(([^/]+/)*[^/.]+)$ $1.php PROBLEM: When I remove the -f i get an internal server error
RewriteCond %{THE_REQUEST} ^GET\s.+\.(php|shtml)
RewriteRule ^(([^/]+/)*[^/.]+)\.(php|shtml)$ http://www.example.com/$1 [R=301,L]
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteRule ^(.*) http://www.example.com/$1 [R=301,L]
RewriteRule ^(([^/]+/)*[^/.]+)$ /$1.php
^GET\s.+\.(php|shtml) I would use ^[A-Z]{3,9}\ /[^.]+\.(php|shtml)\ HTTP/ I have over 300 5-10 year old 301 redirects like this and there is no way I can simplify them. So should I also use RewriteRule for them and move them up?