close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 or 2018 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

PHP HTTPS to HTTP redirect

Thread began 2/11/2011 11:56 am by mrobben375515 | Last modified 3/03/2011 9:39 am by Jason Byrnes | 11251 views | 20 replies |

mrobben375515

PHP HTTPS to HTTP redirect

Hi, a while back you guys gave me a redirect to cause checkout pages to go to https. Now on one of our sites we're having issues after users go to the product pages (where they are redirected to https) and then leave to go back to the rest of the site. The rest of the site has google ads which use js files from an unsecure site so a pop up comes up in IE asking if they only want to few content that was delivered securely. There's no way to change the ads, I've looked for a solution. Is there a redirect that will take the page from https and go back to http? Here's the redirect I was given to go to https.

<?php if((!(isset($_SERVER['HTTPS']))) || ($_SERVER['HTTPS'] == "") || ($_SERVER['HTTPS'] == "off"))header("Location: https://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']); ?>

Sign in to reply to this post

Jason ByrnesWebAssist

on the pages you do not wish to view using https, use this code:


php:
<?php if((!(isset($_SERVER['HTTPS']))) || ($_SERVER['HTTPS'] == "") || ($_SERVER['HTTPS'] == "off"))header("Location: http://" $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']); ?>
Sign in to reply to this post

mrobben375515

I should have mentioned that I tried to change the "Location: https://" to "Location: http://" and didn't have any success. I just tried it again with what you gave me, but it still stays at https... Any other suggestions? I googled it but only found codes for http to https.

Sign in to reply to this post

Jason ByrnesWebAssist

are you using an htaccess rule as well?

If you use an htacess rule, then that will override any php code.

Sign in to reply to this post

mrobben375515

no, i don't have any htaccess rules.

Sign in to reply to this post

Jason ByrnesWebAssist

may be try using this instead:


php:
if ($_SERVER['SERVER_PORT']==443) header("Location: http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
Sign in to reply to this post

mrobben375515

Perfect, thanks Jason

Sign in to reply to this post

Jason ByrnesWebAssist

you're welcome.

Sign in to reply to this post

jmgo

When redirecting from cart.php to index.php clicking the "Home" button a 404 error shows up.
I followed this post directions to redirect my https pages to http ones.
I added the following code to the cart page:
<?php if((!(isset($_SERVER['HTTPS']))) || ($_SERVER['HTTPS'] == "") || ($_SERVER['HTTPS'] == "off"))header("Location: https://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']); ?>
And the following to the index page:
<?php if ($_SERVER['SERVER_PORT']==443) header("Location: http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']); ?>
Other links from https to http works fine but this. I checked the source code and the link seems Ok.

cart.php

Sign in to reply to this post

Jason ByrnesWebAssist

send a copy of the index.php file, it is directing to a file called fakey.php for some reason.

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...