Fix and Join All Domain Redirect Options in One Interface
Let's analyze what the following two interfaces have to offer:
- cPanel > Redirects > www. redirection
- cPanel > Domains > Force HTTPS Redirect
Our task is to redirect the following URLs:
http://site.com/
http://www.site.com/
https://www.site.com/
To:
https://site.com/
www. redirection
NOTE: The rules defined here get written in the domain's .htaccess file.
- Only redirect with www.
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-SSL} !on
RewriteCond %{HTTP_HOST} ^www\.site\.com$
RewriteRule ^(.*)$ "https\:\/\/site\.com\/$1" [R=301,L]
http://site.com/
http://www.site.com/ ==> https://site.com/
https://www.site.com/ <== Why is this not redirected? - Redirect with or without www.
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-SSL} !on
RewriteCond %{HTTP_HOST} ^site\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.site\.com$
RewriteRule ^(.*)$ "https\:\/\/site\.com\/$1" [R=301,L]
http://site.com/ ==> https://site.com/
http://www.site.com/ ==> https://site.com/
https://www.site.com/ <== Why is this not redirected? - Do Not Redirect www.
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-SSL} !on
RewriteCond %{HTTP_HOST} ^site\.com$
RewriteRule ^(.*)$ "https\:\/\/site\.com\/$1" [R=301,L]
http://site.com/ ==> https://site.com/
http://www.site.com/
https://www.site.com/
Force HTTPS Redirect
QUESTION: Where do rules defined here get written?
- http://site.com/ ==> https://site.com/
http://www.site.com/ ==> https://www.site.com/
https://www.site.com/
So to achieve what we want the closest (incomplete) solution we have is to just turn on the Redirect with or without www. option. People usually want to define redirects in one place, which makes this cPanel approach unintuitive and incomplete.
Also, if you turn on Force HTTPS Redirect and Redirect with or without www. at the same time, the other option has no effect.
Suggestions:
- Move the "Force HTTPS Redirect" option to the "Redirects" interface as a part of one integral interface where they won't conflict.
- Make it possible to select multiple domains when creating a redirect in the "Redirects" interface. This would write rules in the user's root .htaccess or to VirtualHost in httpd.conf instead of the domains' root .htaccess.
You can read this suggestion with better color coding here.
Replies have been locked on this page!