Skip to content

Instantly share code, notes, and snippets.

@6ui11em
Forked from crazy4groovy/ht_redirect.txt
Created May 2, 2012 17:53
Show Gist options
  • Save 6ui11em/2578698 to your computer and use it in GitHub Desktop.
Save 6ui11em/2578698 to your computer and use it in GitHub Desktop.
htaccess: Redirection rules
RewriteEngine On
RewriteBase /
### Redirect www to non-www ###
RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]
### Redirect non-www to www ###
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]
### Redirect old non-www to new non-www ###
RewriteCond %{HTTP_HOST} !newdomain.com$ [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301]
### Redirect old www to new www ###
RewriteCond %{HTTP_HOST} !newdomain.com$ [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]
### Simple page redirect ###
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^page_one\.html$ /page_tow.html? [R=301,NE,NC,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment