
Below are two code recipes for your htaccess file to redirect different versions of your domain. Once you have things added you can use this redirect testing tool to verify all the versions of your domain are redirecting properly.
Table of Contents
If you don’t want the WWW
Redirect everything to naked domain https://yourdomain.com
1 2 3 4 5 6 7 8 9 | # BEGIN Redirects RewriteEngine On # 301 redirect www to non-www RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ https://%1/$1 [R=301,L] # 301 redirect to https RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # END Redirects |
If you want the WWW
Redirect everything to https://www.yourdomain.com
1 2 3 4 5 6 7 8 9 | # BEGIN Redirects RewriteEngine On # 301 redirect to www RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # 301 redirect to https RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # END Redirects |
New Industrial HubSpot Theme Released
Do you use HubSpot just for a blog or landing pages? No problem. this HubSpot theme contains the most common types of landing pages and a robust blog template to get you started. Learn More