Redirect to or away from http(s) and www

Learn more about the Redirect to or away from http(s) and www Adobe Muse widget

Use this generator to consolidate your URLs by forcing www (or non-www) and http(s). For more information on why this is important, take a look at this post.


# Examples of valid markup

# Redirect to https and non-www
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

# Redirect to http and www
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{SERVER_NAME}/$1 [R=301,L]
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]


# Add the code that will be
# generated here to your .htaccess file.
Generate Code