Apache HTTP to HTTPS htaccess redirect on CWP – Centos WebPanel Rumi, May 9, 2020 Using Apache as main server (only) : Rewrite rule as follows, this need to be added in your sites .htaccess : RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] Forcing non www to www and https : RewriteEngine On RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC] RewriteRule ^ https://www.%1%{REQUEST_URI} [L,NE,R=301] Forcing www to non www and https : RewriteEngine On RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} ^www\. [NC] RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC] RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301] this also add Permanent 301 Redirect. If upper rules doesn’t works for your Websites And Getting “Too Many redirects” then you should consider below htaccess rule. Using Apache as backend server behind NGINX/VARNISH server : This need to be added in your sites .htaccess : Rewrite rule as follows, this need to be added in your sites .htaccess : SetEnvIf X-Forwarded-Proto "https" HTTPS=on RewriteEngine on RewriteCond %{HTTPS} !=on RewriteCond %{HTTP:X-Forwarded-Proto} !https [NC] RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] OR RewriteCond %{HTTPS} off RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301] OR RewriteCond %{HTTP:X-Forwarded-Proto} =https RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] To force all traffic to use both the www domain and SSL HTTPS, use the following rules: RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{HTTPS} !=on RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] To force all traffic to use non www domain and SSL HTTPS, use the following rules: RewriteEngine On RewriteCond %{HTTP_HOST} ^domain\.tld$ [OR] RewriteCond %{HTTP_HOST} ^www\.domain\.tld$ SetEnvIf X-Forwarded-Proto "https" HTTPS=on RewriteCond %{HTTPS} !=on RewriteCond %{HTTP:X-Forwarded-Proto} !https [NC] RewriteRule ^ https://domain.tld/$1 [L,R=301] OR RewriteEngine On RewriteCond %{HTTP_HOST} ^domain\.tld$ [OR] RewriteCond %{HTTP_HOST} ^www\.domain\.tld$ SetEnvIf X-Forwarded-Proto "https" HTTPS=on RewriteCond %{HTTPS} !=on RewriteCond %{HTTP:X-Forwarded-Proto} !https [NC] RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] replace “domain\.tld” with domain name and tld eg “mysterydata\.com” Related Administrations Configurations (Linux) CentOS Web PanelCWPCWP Panel
How to Disable Network Manager on CentOS 7 May 2, 2022 1. To disable the Network Manager service, perform the following steps: Disable Network Manager with the following commands: CentOS 6, CloudLinux 6, Red Hat Enterprise Linux 6 (RHEL), or Amazon Linux: service NetworkManager stop chkconfig NetworkManager off CentOS 7, CloudLinux 7, or RHEL 7: systemctl stop NetworkManager systemctl disable NetworkManager… Read More
Change Windwos RDP default port 3389 February 15, 2024 Reference is on Windows 10 (should work on other editions too) Step 1: Open the Registry Editor Run the regedit command. You may do this by opening the Start Menu and typing “regedit” into the search bar. Select the option labeled “regedit” with the words “Run command” below it. (Note:… Read More
Install iRedmail on a CentOS 6.8 server March 17, 2018June 10, 2018 We need to set a FQDN hostname before we set up the mail server. On CentOS Linux, hostname is set in two files: Hostname setting: nano /etc/sysconfig/network # Part of file: /etc/sysconfig/network HOSTNAME=demo.iredmail.org Hostname <=> IP address mapping: /etc/hosts. WARNING: Please list the FQDN hostname as the first item. # Part of… Read More