1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How To Make My Domain Automatically Redirect to https?

Discussion in 'BlackHat Lounge' started by Brad100, Feb 5, 2015.

Thread Status:
Not open for further replies.
  1. Brad100

    Brad100 Supreme Member

    Joined:
    Nov 9, 2014
    Messages:
    1,348
    Likes Received:
    966
    Gender:
    Male
    Hey guys, the title is pretty confusing, sorry about that. So, I got a SSL certificate for a site, I got everything working and installed the certificate on the site. But the problem is, when I put "mysite.net" in the address bar, it redirects to www.mysite.net but https:// does not show. But when I put "www.mysite.net" the https:// shows and so does the green lock. What am I doing wrong here?

    [​IMG]

    [​IMG]
     
  2. smashingcreativez

    smashingcreativez Registered Member

    Joined:
    Dec 5, 2014
    Messages:
    91
    Likes Received:
    7
    Occupation:
    Saiyan
    Location:
    Earth
    Refer this page i think it has a solution that u needed .
    serverfault.com/questions/116206/how-do-i-use-htaccess-to-always-redirect-from-http-to-https
     
    • Thanks Thanks x 1
  3. Repulsor

    Repulsor Power Member

    Joined:
    Jun 11, 2013
    Messages:
    766
    Likes Received:
    275
    Location:
    PHP Scripting ;)
    You need to redirect both www and non www versions to HTTPS. Currently, only the www version is being redirected to the https.

    Are you good in htaccess?
     
    • Thanks Thanks x 1
  4. Brad100

    Brad100 Supreme Member

    Joined:
    Nov 9, 2014
    Messages:
    1,348
    Likes Received:
    966
    Gender:
    Male
    Thanks, trying to figure it out now.
    the non www version is being automatically redirected to www, and since the www version is already redirecting to https, shouldn't the non-www version be auto redirected to https? And I'm not really good at htaccess, but doesn't seem too complicated, will try to figure it out and let you guys know If I need further assistance.

    -Thanks.
     
  5. Brad100

    Brad100 Supreme Member

    Joined:
    Nov 9, 2014
    Messages:
    1,348
    Likes Received:
    966
    Gender:
    Male
    UPDATE: It worked. I had to add the following code in my .htaccess :

    Code:
    RewriteEngine On
    RewriteCond %{HTTPS} !^on$
    RewriteRule (.*) https://www.mysite.net/$1 [R,L]
    
    
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
    
    Thread closed, thank you for helping.
     
Thread Status:
Not open for further replies.