I need to find out whether the address someone used to reach a page on my site was using the http or https. I want to disable http access and only allow access to users that use https. Is this possible using php? I tried using $_SEREVER['https'], but the results aren't good enough - it doesn't always work. Any idea?
Unfortunately no, because the parse_url function requires that I first find the entire current url and pass it to it. Finding the entire url including the 'http' part is exactly what I'm having a problem with.
This is definitely possible using .htaccess - at least I would think it is. For instance, you can send anyone trying to get to your site using the "http://" to a page displaying "You need to use https:// to reach the content on this website" or something similar. And then https:// to go to wherever. Unfortunately, I'm not good enough with .htaccess to provide any working code examples.