Apache redirection to SSL
Hi all
Im having trouble with redirection in Apache using WHM and CPanel. I have a main site
domain.com.au
I would like to ensure that all pages redirect to the cannonical a
https://www.domain.com.au
I have been trying to use WHM>>>service configuration>>>apache configuration>>>include editor>>>Post virtual host include
All WHM/CPanel/Webmail/FTP are set to SSL and work fine. I just cant get this to work. All the documentation says that i should use redirect as opposed to mod rewrite and i would like to as it seems cleaner. The above doesnt seem to do anything. I have also used the example shown here https://wiki.apache.org/httpd/RedirectSSL
Can anyone point me in the right direction?
RedirectPermanent / https://www.domain.com.au
All WHM/CPanel/Webmail/FTP are set to SSL and work fine. I just cant get this to work. All the documentation says that i should use redirect as opposed to mod rewrite and i would like to as it seems cleaner. The above doesnt seem to do anything. I have also used the example shown here https://wiki.apache.org/httpd/RedirectSSL
NameVirtualHost *:80
ServerName www.domain.com
Redirect permanent / https://www.domain.com/
ServerName domain.com
DocumentRoot /usr/local/apache2/htdocs/domain.com/
SSLEngine On
# etc...
Can anyone point me in the right direction?
-
[quote="jakeyg, post: 1723302">All the documentation says that i should use redirect as opposed to mod rewrite and i would like to as it seems cleaner.
Hello :) Could you elaborate on what documentation you are referring to? You can use Mod_Rewrite rules in a .htaccess file or the "Redirects" option in cPanel if you want to redirect a website. If you do prefer to edit the VirtualHost, then you can follow the instructions in the following document: Modify Virtualhost Containers With Include Files Thank you.0 -
Add this to your .htaccess file: RewriteEngine on RewriteCond %{HTTPS} !=on RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]0 -
Thanks for the responses. This is where i found the documentation solution is recommended because it is simpler and safer" 0 -
The document I provided will help you to modify the VirtualHost for an account, however the .htaccess rules are more commonly used. Thank you. 0
Please sign in to leave a comment.
Comments
4 comments