Is there anything I could do to improve the following .htaccess code?Options +FollowSymLinksRewriteEngine On# Redirect non-www to www.# http://{domain}/# http://www.{domain}/RewriteCond %{HTTP_HOST} !^www\. [NC]RewriteCond %{HTTP_HOST} !=localhost [NC]RewriteCond %{HTTP_HOST} !=127.0.0.1RewriteCond %{REMOTE_ADDR} !=127.0.0.1RewriteCond %{REMOTE_ADDR} !=::1RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]# Redirect trailing slash to non-trailing slash.# http://www.{domain}/foo/# http://www.{domain}/fooRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^(.+)/$ /$1 [R=301,L]# Redirect trailing .php to extensionless.# http://www.{domain}/foo.php# http://www.{domain}/fooRewriteCond %{THE_REQUEST} ^[A-Z]+\s.+\.php\sHTTP/.+ [NC]RewriteCond %{REQUEST_FILENAME} -fRewriteRule ^(.+)\.php$ /$1 [R=301,L]# Redirect /index to root.# http://www.{domain}/index# http://www.{domain}/RewriteRule ^index$ / [NC,R=301,L]# Forward to version with .php extension.# http://www.{domain}/foo# http://www.{domain}/foo.phpRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME}\.php -fRewriteRule ^(.+)$ /$1.php [L]
301 Redirecting
.htaccess