Forcing http from https?

Discussion in 'Apache' started by gabstero, Mar 31, 2008.

  1. #1
    Hi Gang!

    New kid on the block with a redirect question.

    For some unknown reason, google picked up one of my Added Domains (hosted on the main server) URLs as "https://www.AddedDomain.com". There is no SSL needed for that one.

    I do however have the primary domain where the SSL certification is assigned to (http://www.PrimaryDomain.com)- a shopping cart with later checkout pages where the "https" is needed.

    But I don't want google to show that "https://www.AddedDomain.com" since the AddedDomain is a completely other web page if used with the correct "http://www.AddedDomain.com" URL.

    Now, this might be a root certification problem, meaning that every Added Domain in the Primary hosting will inherit the SSL certification, but until I find that out how to change it, I thought of adding a mod rewrite of some sort that forces every hit that lands on "https://www.AddedDomain.com" to be redirected to "http://www.PrimaryDomain.com".

    How would that code look like in the .htaccess file?

    Does that make sense?

    thanks!
    gabstero.
     
    gabstero, Mar 31, 2008 IP
  2. fsmedia

    fsmedia Prominent Member

    Messages:
    5,163
    Likes Received:
    262
    Best Answers:
    0
    Trophy Points:
    390
    #2
    fsmedia, Mar 31, 2008 IP
  3. gabstero

    gabstero Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks for the VERY QUICK reply!

    Unfortunately that threat is talking about adding or removing the "www". I need to replace the "https" with "http".

    thanks,
    gabstero.
     
    gabstero, Mar 31, 2008 IP
  4. fsmedia

    fsmedia Prominent Member

    Messages:
    5,163
    Likes Received:
    262
    Best Answers:
    0
    Trophy Points:
    390
    #4
    yeah, it should help actually.

    because SSL is on port 443, so use the above code to check if the port being used is 443 or not. if it's not being used, forward to the https

    RewriteCond %{HTTP_HOST}!^www\.example\.com
    RewriteCond %{SERVER_PORT}!^443$
    RewriteRule (.*) https://www.example.com$1 [R=301,L]

    that will check to see if https is being used or not, if it's not, then it will forward to https

    (I believe that should work, I haven't tested it.)
     
    fsmedia, Mar 31, 2008 IP
  5. gabstero

    gabstero Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks for the reply!!

    Unfortunately it didn't work :-(
    It broke "http://www.example.com" so I had to remove it.

    I think I didn't express myself correctly. I need the exact inverse from what most are after. I need to go from:

    https to http

    in that case how would the mod rewrite be written?

    thanks a ton!
    gabstero
     
    gabstero, Apr 9, 2008 IP
  6. Ni9htRider

    Ni9htRider Peon

    Messages:
    98
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    If you have SSL on port 433 (default), you would make .htaccess in the root folder for your SSL directory, and fill it with the following code:

    
    RewriteCond %{HTTP_HOST}!^nrglab\.org
    RewriteCond %{SERVER_PORT}!^443$
    RewriteRule (.*) https://secured.nrglab.org$1 [R=301,L]
    
    Code (markup):
    (this is what I use on my website everytime I want people to view my site from my SSL)
     
    Ni9htRider, Apr 17, 2008 IP
  7. gabstero

    gabstero Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Thanks a lot -

    but that still is noo good for my issue that is the actual inverse of the solution you provided. Note that I need to redirect FROM and https page TO a http.

    Thanks a lot,
    Gabstero
     
    gabstero, Apr 21, 2008 IP