Redirect http to https in WHM
Hi :)
I have a VPS with several websites, and in one of them, I want to redirect from http to https.
Based on the Apache documentation I can do with this:
I understand that the best way to do this in the WHM is: Home> Service Configuration> Apache Configuration> Include Editor And here is where I have a couple of questions: 1) Should I put the above code in: Pre Virtual Host include o Post Virtual Host include? 2) If in the future I would like to edit or delete the added code: Can I do it in the WHM? Or should I edit / delete the file included via SSH? Thanks for the help friends and apologize if my English is faulty. Eduardo
ServerName www.example.com
Redirect / https://www.example.com/
I understand that the best way to do this in the WHM is: Home> Service Configuration> Apache Configuration> Include Editor And here is where I have a couple of questions: 1) Should I put the above code in: Pre Virtual Host include o Post Virtual Host include? 2) If in the future I would like to edit or delete the added code: Can I do it in the WHM? Or should I edit / delete the file included via SSH? Thanks for the help friends and apologize if my English is faulty. Eduardo
-
Hello, You can actually add the following entry to the .htaccess file within the account's home directory: RewriteEngine On RewriteCond %{SERVER_PORT} !=443 RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC] RewriteRule ^$ https://www.example.com/%{REQUEST_URI} [R,L]
This is easier for the end-user to modify should they decide to change this behavior in the future. Thank you.0 -
Thanks Michael ! 0 -
Shouldn't that last line be: RewriteRule .* https://www.example.com/%{REQUEST_URI} [R,L]
Rather than:RewriteRule ^$ https://www.example.com/%{REQUEST_URI} [R,L]
which will only redirect the home page but no other pages at www.example.com.0 -
Yes, there are several valid alternatives that redirect the pages differently than the example provided. Thank you. 0 -
This worked to me ::) RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}
0 -
@aadii786 -it's important to note that your change would affect all the vhosts on the system, instead of just one individual domain. If you want that behavior, that's fine, but I just wanted to mention that. 0
Please sign in to leave a comment.
Comments
6 comments