Results 1 to 2 of 2

Thread: [How To] Redirect from HTTP to HTTPS using mod_rewrite

  1. #1
    sergey is offline Master Glow Jedi
    Join Date
    Aug 2005
    Posts
    472

    Default [How To] Redirect from HTTP to HTTPS using mod_rewrite

    We can achieve this using mod_rewrite which is already compiled into your Apache web server here at GlowHost.com

    This will redirect any access to the non-secure site to the secure site at https://yourdomain.com

    (Provided you have an SSL certificate for your domain)

    Stick this in your .htaccess file:

    Code:
     
    RewriteEngine On 
    RewriteCond %{SERVER_PORT} !^443$ 
    RewriteRule (.*) https://yourdomain.com/ [L]
    If you want to simply redirect all requests for a certain directory, for example your shopping cart installation, you can do something like:

    Code:
     
    RewriteEngine On 
    RewriteCond %{REQUEST_URI} ^/cart/.*
    RewriteCond %{SERVER_PORT} !^443$ 
    RewriteRule (.*) https://yourdomain.com/ [L]
    Last edited by Matt; 05-13-2008 at 01:26 PM.

  2. #2
    Matt's Avatar
    Matt is offline GlowHost Administrator
    Join Date
    Jan 2005
    Location
    Behind your monitor
    Posts
    5,959

    Default

    Here is a thread that describes how to redirect everything to the "www" version of your website, so that anything like http://domain.com will be converted to http://www.domain.com

    Redirect to www using mod_rewrite
    Last edited by Matt; 05-13-2008 at 01:25 PM.
    Send your friends and site visitors to GlowHost and get $125 plus bonus!
    GlowHost Affiliate Program | Read our Blog | Follow us on X |

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14