Author Topic: redirect all requests and non www to http://www.  (Read 1474 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
redirect all requests and non www to http://www.
« on: February 24, 2017, 01:41:33 PM »
In 2017 someone may require secure connections as its good, and especially for SEO

There is now visual way to achieve this in cwp

lets asume u use apache

disable any redirect u may have right now as they will interfere with the lets encrypt module
so in vhost.conf or .htaccess remove any redirects

But only for the domain u dont use or want to change
delete the folders in
 /etc/letsencrypt/live
 /etc/letsencrypt/archive
 /etc/letsencrypt/renewal

Then via the cwp gui create the certificates again with the www alias checked

Now add in  /usr/local/apache/conf.d/vhosts-ssl-letsencrypt.conf (per domain)
or in .htaccess in webroot of domain (per domain)

Or add
RewriteOptions InheritDown
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]

to httpd.conf (then all domains will redirect to https://www.