Forum Moderators: phranque
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^([^/]+)/$ $1.html RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
AddType application/x-httpd-php htm html php
AddHandler application/x-httpd-php .htm .html
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mysite.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L] [edited by: jdMorgan at 12:40 am (utc) on May 13, 2010]
[edit reason] Please use example.com only [/edit]
AddType application/x-httpd-php htm html php
AddHandler application/x-httpd-php .htm .html
#
RewriteEngine On
#
# Externally redirect to add missing trailing slashes if no filetype on requested URL-path
RewriteCond $1 !\.[a-z0-9]{1,5}$ [NC]
RewriteRule ^(.*[^/])$ http://www.example.com/$1/ [R=301,L]
#
# Externally redirect direct client requests for URLs
# with .html extensions to new extensionless URLs
RewriteCond %{THE_REQUEST} ^[A-Z]\ /([^/]+/)*([^.]+\.)+html([?#][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.html$ http://www.example.com/$1/ [R=301,L]
#
# Externally redirect requests for non-blank non-canonical hostname to canonical hostname
RewriteCond %{HTTP_HOST} !^(www\.mysite\.com)?$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
#
# Internally rewrite extensionless URL-paths to .html files if they
# end in a slash, do not resolve to physically-existing directories,
# and do resolve to existing files when ".html" is appended.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^([^/]+)/$ /$1.html [L]
[edited by: jdMorgan at 2:47 am (utc) on May 13, 2010]
AddType application/x-httpd-php htm html php
AddHandler application/x-httpd-php .htm .html
#
RewriteEngine On
#
# Externally redirect to remove trailing slashes if not a
# directory request, to enforce clean extensionless URLs
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(([^/]+/)*[^/]+)/$ http://www.example.com/$1 [R=301,L]
#
# Externally redirect direct client requests for URLs
# with .html extensions to new extensionless URLs
RewriteCond %{THE_REQUEST} ^[A-Z]\ /([^/]+/)*([^.]+\.)+html([?#][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.html$ http://www.example.com/$1 [R=301,L]
#
# Externally redirect requests for non-blank
# non-canonical hostnames to canonical hostname
RewriteCond %{HTTP_HOST} !^(www\.mysite\.com)?$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
#
# Internally rewrite extensionless URL-paths to .html files
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(([^/]+/)*[^./]+)$ /$1.html [L]