Please Login or Register

Knowledgebase

[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]

 






Was this answer helpful?
Add to Favourites Add to Favourites   Print this Article Print this Article
Also Read
Can I modify PHP.ini? (Views: 1241)

Powered by WHMCompleteSolution

Language:


Web Hosting
Client Login
Web Hosting

Email

Password

Remember Me


Web Hosting
Search
Web Hosting




Follow Us on Twitter