20i Reseller Hosting

Easiest way to edit https/SSL sites locally?

Discussion in 'Scripts and Coding' started by boxfish, Mar 23, 2018.

  1. boxfish United Kingdom

    boxfish Well-Known Member

    Joined:
    Jul 2010
    Posts:
    1,008
    Likes Received:
    63
    When making significant changes to any of my sites (mainly WordPress) I've always worked on them locally using WAMP.

    Since having to introduce https to all the live sites I'm now struggling to edit them locally as my system doesn't currently have SSL so the sites don't work/display as expected.

    I've done some research and tried a few methods using OpenSSL but have failed so far in getting something set up.

    Is there an easy way to do it?

    1) Ideally that supports Virtual Hosts
    2) Ideally works automatically and doesn't need setting up separately for every site

    or is there a way to just spoof the https instead of http? I don't need the sites to actually be encrypted, I just need the links to work, I'm fine with certificate errors

    Thanks
     
  2. Domain Forum

    Acorn Domains Elite Member

    Joined:
    1999
    Messages:
    Many
    Likes Received:
    Lots
    articles.co.uk
     
  3. seemly

    seemly Well-Known Member

    Joined:
    Feb 2011
    Posts:
    1,227
    Likes Received:
    193
    I assume you you absolute URL's then, rather than relative?

    Absolute URL example:
    Code:
    <a href="http://www.yourdomain.co.uk/some-page">some link</a>
    
    Relative URL example:
    Code:
    <a href="/some-page">some link</a>
    
    For external assets (CSS and Javascript) from a CDN, you can adjust the protocol part of the URL:
    Instead of defining the protocol like this:

    Code:
    <script src="https://maxcdn.com/some-library/some-plugin.js"></script>
    
    Just leave it out:
    Code:
    <script src="//maxcdn.com/some-library/some-plugin.js"></script>
    
     
    • Like Like x 1
  4. seemly

    seemly Well-Known Member

    Joined:
    Feb 2011
    Posts:
    1,227
    Likes Received:
    193
    Testing forms may cause an issue, testing local v.s. production environment.
    If there is any other specific issue, post it here so we can maybe offer alternatives or work arounds.
     
    • Like Like x 1
  5. Adam H

    Adam H Well-Known Member Exclusive Member

    Joined:
    May 2014
    Posts:
    1,609
    Likes Received:
    218
    Or use absolute URL's such as :

    Code:
    <a href="<?php echo home_url(); ?>/rest-of-url "> Something </a>
    
    So it changes depending on Site URL. I personally use a staging plugin for small tweaks and to test plugin updates etc. Or have a subdomain where I deploy everything I need from there and then just upload the new database to the live and then doing a search and replace for all URL instances. Takes 10 mins max.

    Some web hosts also provide a staging environment for that purpose.
     
    • Like Like x 1
  6. boxfish United Kingdom

    boxfish Well-Known Member

    Joined:
    Jul 2010
    Posts:
    1,008
    Likes Received:
    63
    Thanks for your responses guys.

    Yes, it was the absolute paths that were causing the issue.

    It seems I was actually really close to having it working when I posted this thread - it's working now.

    Even though you can set up SSL on your own computer and load https pages, apparently because it is a self-signed certificate it still shows as 'Not Safe' in Chrome, and every time you click a link within the site you have to confirm to proceed, plus it won't load lots of stuff, like images or .css files with absolute paths.

    The fix is a setting in Chrome which allows you to have unsafe https on localhost: chrome://flags/#allow-insecure-localhost

    Once you activate that, you have to accept it is unsafe when you first load the site, but then everything loads as it should and no further warnings appear
     
    • Like Like x 1
    • Informative Informative x 1
  7. seemly

    seemly Well-Known Member

    Joined:
    Feb 2011
    Posts:
    1,227
    Likes Received:
    193
    Glad you sorted it.