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.

Redirect to https only if it is working?

Discussion in 'Apache' started by postcd, Sep 22, 2017.

  1. #1
    Hello,

    can you share a method (if exist) on how to redirect HTTP:// site to HTTPS:// but only if the SSL certificate for that domain is signed/working?

    Because i do not want to force SSL while i think SSL may stop working (expired certificate or such). I am using Apache, PHP 5.x, SuPHP
     
    postcd, Sep 22, 2017 IP
  2. thewolfie

    thewolfie Greenhorn

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #2
    It cannot be achieved with mod rewrite (99.9% of the times the redirects are done using rewrite). A plugin for your website might be able to do that for you, but I doubt any will exist.

    I suggest you just put a monitor for the ssl certificate, check this article out https://geekflare.com/monitor-ssl-certificate-expiry/
     
    thewolfie, Oct 12, 2017 IP
  3. hostechsupport

    hostechsupport Well-Known Member

    Messages:
    413
    Likes Received:
    23
    Best Answers:
    7
    Trophy Points:
    138
    #3
    Hello postcd,
    Make sure the lines beginning RewriteCond and RewriteRule immediately follow the already-existing RewriteEngine On. Please note that you have to make sure that the SSL is always active and not expired cause .htaccess code doesn't know that.
     
    hostechsupport, Oct 26, 2017 IP
  4. lektrikpuke

    lektrikpuke Well-Known Member

    Messages:
    297
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    113
    #4
    Seeing as how you have PHP, I would use that. You could have an include for all your pages that goes out
    $contentToParse = file_get_contents('https://www.yoursiteviahttps.com/testpage.html');
    Code (markup):
    , parses the returned content for some term/word on test page, if exists term, https is up and redirect (via PHP or javascript) to https, else serve up http. You could also just parse for an error condition (perhaps in header). Of course, it goes without saying, this will add a bit of overhead to page load.
     
    lektrikpuke, Jan 30, 2018 IP