Author Topic: redirect all requests and non www to http://www.  (Read 4762 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.

Offline
*
Re: redirect all requests and non www to http://www.
« Reply #1 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]

Offline
*****
Re: redirect all requests and non www to http://www.
« Reply #2 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" ;)
You can ask me to solve any problem with your server for some money in pm  ;)
Services Monitoring & RBL Monitoring
http://centos-webpanel.com/services-monitor
Join our Development Team and get paid !
http://centos-webpanel.com/develope-modules-for-cwp

Installation Instructions
http://centos-webpanel.com/installation-instructions
Get Fast Support Here
http://centos-webpanel.com/support-services

Offline
*
Re: redirect all requests and non www to http://www.
« Reply #3 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.

Offline
****
Re: redirect all requests and non www to http://www.
« Reply #4 on: August 11, 2019, 01:54:54 PM »
None of my domains are automatically forwarding to https like they did before.  Whats going on?

Offline
*****
Re: redirect all requests and non www to http://www.
« Reply #5 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?
You can ask me to solve any problem with your server for some money in pm  ;)
Services Monitoring & RBL Monitoring
http://centos-webpanel.com/services-monitor
Join our Development Team and get paid !
http://centos-webpanel.com/develope-modules-for-cwp

Installation Instructions
http://centos-webpanel.com/installation-instructions
Get Fast Support Here
http://centos-webpanel.com/support-services