1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Allow my website to be accessed with http AND https

Discussion in 'Apache' started by Reikla, Jun 7, 2015.

  1. #1
    Hi,
    I recently got a SSL-certificate for my website. Now the old links to my website (using only http) doesnt work, the visitors just getting redirected to my index page. How can I change my .htaccess so both http and https works, but keep https as the preferred? Or even better, redirect old http links to https? I'm not using www.

    My current .htaccess:
    Thanks
    SEMrush
     
    Reikla, Jun 7, 2015 IP
    SEMrush
  2. O-D-T

    O-D-T Member

    Messages:
    180
    Likes Received:
    10
    Best Answers:
    3
    Trophy Points:
    43
    #2
    Hi, try any of these:

    1)
    RewriteEngine On
    RewriteCond %{HTTPS} !^on$
    RewriteRule (.*) https://yourdomain/$1 [R,L]
    
    Code (markup):
    2)
    RewriteEngine on
    RewriteCondition %{SERVER_PORT} !^443$
    RewriteRule ^(.*)$ https://yourdomain/$1 [R=301,L]
    
    Code (markup):
    3)
    RewriteEngine On
    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)$ https://yourdomain/$1 [R=301,L]
    
    Code (markup):

    The crucial seems to be the "$1" part.
     
    O-D-T, Jun 8, 2015 IP
  3. Reikla

    Reikla Well-Known Member

    Messages:
    164
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    100
    #3
    Sorry for late reply, but thanks! Will try them out and let you know how it goes.
     
    Reikla, Jun 11, 2015 IP