How do I redirect my domain to show https://www in the URL bar? Print

  • 0

Let's say you have the domain and wish to have it automatically redirect to (note the https:// and www.) when visitors go to, this can be easily achieved using htaccess!

Create (or modify) a file called ".htaccess" in your domain's root directory, and add the following:

RewriteEngine On
RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
# [NC] is a case-insensitive match
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

That's it, you're done! 

Please note, you may need to clear your browser cache (or try another web browser) to see the change take effect. 

Was this answer helpful?

« Back

Ethernet Servers Ltd
124 City Road

Registered Limited Company: #09114946
Telephone: +44 330 043 1258
Email: [email protected]

Copyright © 2013 - 2022 - Ethernet Servers Ltd - All Rights Reserved.

Proudly serving customers in 118 countries since September 2013!