Jump to content

Switch PHP on site from HTTP to HTTPS, a few things return back to HTTP


Barsinister88

Recommended Posts

I have DRBGuestbook which was written some time ago and the original site that we got the code from no longer exists.  Basically since Google will be marking all sites insecure in June if they don't have SSL I am making my site SSL.  The main pages of the guestbook work fine and the posting and things seem to work but when I log in with administrator it switches from HTTPS back to HTTP after inputting the password.  I am going to attach the entire guestbook as is exists now in hopes that someone can help me make the adjustment that is needed for the pages to stay on HTTPS through the entire processes.  Thank you!

 

guestbook021918.zip

Link to comment
Share on other sites

It's a bit of a pain to go through the whole file ourselves...

 

If you're using HTTPS fine and then it sends you to HTTP then there must be a redirect somewhere that explicitly says "http://". So look for that - it might be in PHP code or not.

header("Location: http://" . $website . "/a/b/c");
You could add the 's' in there, but easier is to not have that portion at all. Remove the http:// and the domain name so it's just the URL path:

header("Location: /a/b/c");
  • Like 1
Link to comment
Share on other sites

We use Apache's .htaccess to enforce SSL browsing:

 

RewriteEngine on

#enforce SSL
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
For images, scripts, etc, we use relative paths:

 


<img src="//images.oursite.com/path/to/images/foo.jpg" alt='cat'>
<script src="//code.jquery.com/jquery-1.9.1.min.js"></script>
This ensures that we don't have mixed-content blocking going on in the browser, leading to missing images or JS functionality. Edited by dalecosp
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.