Control Web Panel

WebPanel => Information => Topic started by: martexx on February 24, 2017, 01:41:33 PM

Title: redirect all requests and non www to http://www.
Post by: martexx 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.
Title: Re: redirect all requests and non www to http://www.
Post by: itz3ima on August 08, 2019, 07:56:40 AM
it worked for me, add in .htaccess

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http://example.org/$1 [L,R=301,NC]
Title: Re: redirect all requests and non www to http://www.
Post by: Igor S. on August 09, 2019, 08:19:24 AM
There are too many ways for the redirect.
Try gooling by "redirect non-ww to www .htaccess" ;)
Title: Re: redirect all requests and non www to http://www.
Post by: ekgrad on August 09, 2019, 08:33:10 AM
No need of any manual configuration. If you are using nginx->apache as web server, just use the "force https" nginx template in your web server settings.
Title: Re: redirect all requests and non www to http://www.
Post by: pixelpadre on August 11, 2019, 01:54:54 PM
None of my domains are automatically forwarding to https like they did before.  Whats going on?
Title: Re: redirect all requests and non www to http://www.
Post by: Igor S. on August 23, 2019, 08:04:40 AM
None of my domains are automatically forwarding to https like they did before.  Whats going on?

maybe you have changed apache to nginx which do not understand .htaccess?