Find the answer to your Linux question:
Results 1 to 4 of 4
First off, I know absolutely nothing about coding so please be gentle and reply as if I'm an idiot! I have a website on a Linux based virtual server so ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2008
    Posts
    2

    Unhappy Redirecting http to https on virtual server


    First off, I know absolutely nothing about coding so please be gentle and reply as if I'm an idiot!

    I have a website on a Linux based virtual server so it uses both ports 80 and 443. I need visitors to go to the https version of the site for payment collection but as most users will not type in https or http they are immediately directed to http.

    * [moderator edit: removed corrupted links]

    various forums have advised that the .htaccess file should read:

    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

    and this should work. My htaccess files does read this, but it doesn't work.

    Can anyone help!! Please speak very s-l-o-w-l-y if you are kind enough to do so.

    Thanks
    Last edited by oz; 01-25-2008 at 09:12 PM. Reason: removed corrupted links

  2. #2
    Just Joined!
    Join Date
    Jan 2008
    Posts
    2
    I should add that the above has been corrupted after posting and it should read that if a user types www.myoldwebaddress.com into their address bar what is loaded is https://www.myoldwebaddress.com

  3. #3
    Linux Guru
    Join Date
    Nov 2007
    Posts
    1,756
    The .htaccess code you have assumes that Apache is running with mod_rewrite support compiled and enabled. If it's your Apache, you can correct this. If it's a hosting company, they may/may not change it for you. You'll have to contact them.

    There are several other ways to redirect requests. You may want to look at the Javascript or PHP methods.

  4. #4
    Linux Newbie athlon_crazy's Avatar
    Join Date
    Sep 2007
    Location
    Malaysia
    Posts
    132
    For specific vhost:

    </VirtualHost>
    <VirtualHost *:80>
    ServerAdmin admin@domain.com
    DocumentRoot /mnt/hda5/www
    ServerName domain.com
    ServerAlias www.domain.com
    RewriteEngine On
    RewriteCond &#37;{SERVER_PORT} !^443
    RewriteRule (.*) https://www.domain.com/ [R]
    </VirtualHost>

    put in your httpd.conf / vhosts.conf. Tested & working on Apache...

Posting Permissions

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