Site icon N77 Design | NickClaeboe.com

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]

Exit mobile version