I want to determine if the user is browsing a protected page and redirects if not (to log in).
However, my site is navigating through a proxy server before I see that the server and proxy variables (right now) tell me that $_SERVER['HTTPS'] is 'on' when the URI clearly points to something else. It also shows 'on' when the user navigates “safely”.
Moving between http:// and https:// leads to the conclusion that $_SERVER['SERVER_PORT'] = 443 .
I have no way to make changes to the proxy server, so I want to know:
- Does PHP have any other options for discovering the truth or ...
- I stuck with JavaScript mechanisms for detection and redirection.
I have earned this question for ideas, but they mostly revolve around the $_SERVER['HTTPS'] variable, which is trustworthy. Bah!
It seems that this question is experiencing at least something similar, but he / she was able to solve it by adapting the apache solution.
Are there any other PHP SERVER variables or tricks to detect where the user URI begins? The only difference between the $ _SERVER variables when viewing my http site versus https:
- _FCGI_X_PIPE_ (displayed randomly)
- HTTP_COOKIE (sto-id-47873 is included in the insecure version, but I didn’t ) there
- REMOTE_ADDR (This and the next two continue to change inexplicably!)
- REMOTE_HOST
- REMOTE_PORT ('proxy people', why are you constantly changing this?)
Are any of these elements strong enough to put on one weight without breaking it down and causing pain later? Perhaps I should not trust anything filtered through a proxy server, as it can change at any given time.
Here is my plan to use JavaScript for this purpose; is this the best i have?
function confirmSSL() { if(location.protocol != "https:") { var locale = location.href; locale = locale.replace(/http:\/\//,"https://"); location.replace(locale); } } <body onLoad="confirmSSL()">...
I think if a user has disabled JavaScript in my community, then they hopefully know what they are doing. They must be able to manually enter the safe area. What <noscript> sentences would be common practice? Something like this, maybe ?:
<noscript> Go through https: //blah.more.egg/fake to protect your information. </noscript>
PHP solutions that work (with a good explanation) will give preference to the correct answer. Feel free to submit a better JavaScript implementation or link to it.
Many thanks!