Forum Moderators: phranque
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
Options -Indexes
RewriteEngine On
RewriteBase /
#
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*[^/])$ /$1.php [L]
RewriteEngine On
RewriteBase /
#
RewriteCond $1 !\.(php|gif|jpe?g|png|ico|css|js)$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*[^/])$ /$1.php [L]
IndexOptions FancyIndexing
Options All
RewriteEngine on
#
# Externally redirect client /index page requests to "/"
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]+/)*index\.html?
RewriteRule ^(([^/]+/)*)index\.html?$ http://www.example.com/$1 [R=301,L]
#
# Externally redirect client requests contains htm/html extension to extensionless URL
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*[^.]+\.html?
# externally redirect to extensionless URI
RewriteRule ^(([^/]+/)*[^.]+)\.html?$ http://www.example.com/$1 [R=301,L]
#
# Externally redirect non-blank non-canonical hostname requests to canonical hostname
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
#
# If requested extensionless URL-path does not resolve to an existing directory
RewriteCond %{REQUEST_FILENAME} !-d
# and if requested extensionless URL-path plus ".htm" does resolve to an existing file
RewriteCond %{REQUEST_FILENAME}.htm -f
# then append ".htm" to resolve the actual filename
RewriteRule ^(([^/]+/)*[^./]+)$ /$1.htm [L]