Forum Moderators: phranque
RewriteEngine on
# old to new
redirect 301 /sub1/sub2/html.html http://uiqe.com/sub3/new
# redirect all non-canonical domains to canonical domain
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^uiqe\.com$
RewriteRule ^(.*) http://uiqe.com/$1 [R=301,L]
# trailing slash
RewriteCond %{REQUEST_URI} !(.*)/$
# directory index
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html\ HTTP/
RewriteRule ^(.*)index\.html$ http://%{HTTP_HOST}/$1 [R=301,L]
# force extensionless url's
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*[^/.]+\.html\ HTTP/
RewriteRule ^(([^/]+/)*[^/.]+)\.html$ http://%{HTTP_HOST}/$1 [R=301,L] RewriteEngine on
RewriteBase /
# always add a trailing slash to folders
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*[^/])$ /$1/ [R=301,L]
# rewrite index.html to folder (directory index)
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html$ http://uiqe.com/$1 [R=301,L]
# old to new (UNTOUCHED)
redirect 301 /sub1/sub2/html.html http://uiqe.com/sub3/new
# force extensionless url's
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*[^/.]+\.html\ HTTP/
RewriteRule ^(([^/]+/)*[^/.]+)\.html$ http://uiqe.com/$1 [R=301,L]
# redirect all non-canonical domains to canonical domain
RewriteCond %{HTTP_HOST} !^uiqe\.com$
RewriteRule ^(.*) http://uiqe.com/$1 [R=301,L] ^(.*[^/])$ simplifies to !/$ here. The target should also include the protocol and domain name. .* pattern to fix in the "index" rule. Redirect 301 /sub1/sub2/html.html http://uiqe.com/sub3/new RewriteRule ^sub1/sub2/html\.html http://uiqe.com/sub3/new [R=301,L] RewriteEngine on
RewriteBase /
# trailing slashes
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^!/$ http://uiqe.com/$1/ [R=301,L]
# rewrite index.html to folder (directory index)
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html$ http://uiqe.com/$1 [R=301,L]
# old to new
RewriteRule ^sub1/sub2/html\.html$ http://uiqe.com/sub3/new [R=301,L]
# extensionless url's
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*[^/.]+\.html\ HTTP/
RewriteRule ^(([^/]+/)*[^/.]+)\.html$ http://uiqe.com/$1 [R=301,L]
# canonical hostname
RewriteCond %{HTTP_HOST} !^uiqe\.com$ [NC]
RewriteRule ^(.*)$ http://uiqe.com/$1 [R=301,L]