Knowledgebase
Portal Home > Knowledgebase > Web Hosting/General > [How To] Redirect from HTTP to HTTPS using mod_rewrite
[How To] Redirect from HTTP to HTTPS using mod_rewrite
| When handling sensitive data such as payment information logins, you may wish to require uses use SSL (Secure Socket Layers).
Redirecting users from http:// (unsecure) to https:// (secure) can easily be achieved using mod_rewrite which is set up as standard with all XDnet shared packages (VPS and Dedicated clients can set this option them selves via WHM).
The following will redirect users from http://yourdomain.com to https://yourdomain.com (This tutorial assumes you have a SSL Certificate, if you do not or would like a shared certificate please contact support@xdnet.co.uk or open a support ticket).
Add the followingto your .htaccess file:
CODE:
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://yourdomain.com/$1 [L]
While HTTPS is all well and good it is simply not needed for the large majority of webpages, and while it is only slight it is slower than normal HTTP connections (because of the extra security layers). For most people secure sockets are only wanted on the order/client sections so we can apply this redirect to only these folders:
CODE:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/cart/.*
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://yourdomain.com/$1 [L]
|
Also Read
Powered by WHMCompleteSolution