How Do I Redirect Http:// And Non-www Requests to Https://www.?

  • updated
  • Answered

When people visit my site without www or without https I would like them redirected to

I have the following code in htaccess:

RewriteEngine On

RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)${REQUEST_URI} [L,R=301,NE]

RewriteCond %{HTTP_HOST} ^ [NC]
RewriteRule ^(.*)$$1 [L,R=301,NC]

It works in some cases, but if I visit it does not redirect.

Can you help?

  • Answered

Hello Tim,

Thanks for posting your question regarding redirecting http:// and non-www requests to https://www. This is generally controlled by the Content Management System that you used to build your website. Depending on that software you can adjust this in their settings. Although you may be able to code your .htaccess file for redirects, it may disrupt the functionality of the CMS. How did you build your website?

I look forward to your response to assist you further.


Carlos D.