Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save joshuaadrian/de88d43e693ec8e73b178974151d5d46 to your computer and use it in GitHub Desktop.
Save joshuaadrian/de88d43e693ec8e73b178974151d5d46 to your computer and use it in GitHub Desktop.
htaccess https redirect
#Redirect Non-WWW to WWW with SSL
RewriteCond %{ENV:HTTPS} !on [NC]
RewriteRule ^(.*)$ https://www.domain.com/$1 [NC,R=301,L]
#Redirect Non-WWW to WWW
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L]
#Redirect alternative domains
RewriteCond %{HTTP_HOST} ^domain.com.php53-13.dfw1-1.websitetestlink.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.domain.com.php53-13.dfw1-1.websitetestlink.com$ [NC]
RewriteRule (.*) https://www.domain.com/$1 [R=301,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment