N77 Design
← Blog

Set .HTACCESS File To Force NON-WWW SSL HTTPS

I often come across sites that need SSL but require the path to be force with NON-www. Below is a handy snipped of code to place in your root folder in the .htaccess file. You can simply copy this code and paste it in to

Set .HTACCESS File To Force NON-WWW SSL HTTPS

I often come across sites that need SSL but require the path to be force with NON-www.

Below is a handy snipped of code to place in your root folder in the .htaccess file. You can simply copy this code and paste it in to force all incoming urls to drop www and only use non-www urls, e.g.: https://sitename.com.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)(.+) [OR]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?(.+)
RewriteRule ^ https://%2%{REQUEST_URI} [R=301,L]

Original route
/2016/09/24/set-htaccess-file-force-non-www-ssl-https/
Author
n77design
Categories
Servers, Tutorial

Want a website that does the work?

Tell me what you’re building, what needs to change, and when you’d like to launch.

Start a project Based in Atlanta · One point of contact