Page 1 of 1
$_SERVER equivalent for http://, SSL, and WWW?
Posted: Mon Feb 02, 2009 8:16 pm
by JAB Creations
What is the $_SERVER or equivalent for http://, with or without SSL, and WWW? I'm looking all over the predefined variables on php.net without any luck.

Re: $_SERVER equivalent for http://, SSL, and WWW?
Posted: Mon Feb 02, 2009 8:19 pm
by Eran
Re: $_SERVER equivalent for http://, SSL, and WWW?
Posted: Mon Feb 02, 2009 8:22 pm
by JAB Creations
Gah...I guess not.

Thanks though. More procedural programming to work towards my CMS goal in the other thread.

Re: $_SERVER equivalent for http://, SSL, and WWW?
Posted: Mon Feb 02, 2009 8:24 pm
by Eran
?
what exactly you are looking for, I thought it was the protocol of the request?
Re: $_SERVER equivalent for http://, SSL, and WWW?
Posted: Mon Feb 02, 2009 8:31 pm
by requinix
I doesn't make sense for a webserver to do anything over a protocol other than HTTP. It's like... I don't even know, but it's like something that's unusual.
$_SERVER["HTTPS"] is defined for a secure connection. If defined use https otherwise use http. "www"? That's the server name. Look in $_SERVER["HTTP_HOST"] for what the browser requested, ["SERVER_NAME"] for what "server" handled the request.
Re: $_SERVER equivalent for http://, SSL, and WWW?
Posted: Mon Feb 02, 2009 8:40 pm
by Eran
A webserver might not, but PHP might. For example a cron, or a request from a mail stream. Not sure what JAB had in mind exactly...
Re: $_SERVER equivalent for http://, SSL, and WWW?
Posted: Mon Feb 02, 2009 9:03 pm
by JAB Creations
I don't want to go off-topic but in order to test this I was trying to see what would happen if I requested the same test page via SSL (and got a 403 error)...12 hours towards the end of my day (and smack in the middle of the thread

). Any way I can do a very simple if condition (once I personally verify the result for SSL, 1.0, and 1.1) to construct that part of the URL.
No, I'm just trying to make sure when I construct the URL that it's always 100% the exact same as the requested URL. In example I use an Apache script that redirects non-WWW requests to the same URL
with WWW, if for some reason I forgot this I'd want PHP to dynamically handle it with or without the WWW versus breaking altogether if possible?
Re: $_SERVER equivalent for http://, SSL, and WWW?
Posted: Mon Feb 02, 2009 9:06 pm
by Eran
What about $_SERVER['REQUEST_URI']? returns the requested address
Re: $_SERVER equivalent for http://, SSL, and WWW?
Posted: Mon Feb 02, 2009 9:09 pm
by JAB Creations
What I'm trying to do...well I'm trying to recreate the URL to then explode it against the
$cms->get('base') (element) href value (from the other thread). I'll take $piece[1] and determine the path of the current file to determine what row in the cms_pages MySQL table contains all the CMS information. So in simple terms, I'm trying to determine the page's relevant string to use in the MySQL query that will return all the CMS information stored in database (meta, title, etc) as was the topic in
this thread.
Re: $_SERVER equivalent for http://, SSL, and WWW?
Posted: Mon Feb 02, 2009 9:46 pm
by JAB Creations
pytrin wrote:What about $_SERVER['REQUEST_URI']? returns the requested address
It doesn't return any of the following...
http://
https://
http://www.
https://www.
With
$_SERVER['REQUEST_URI'] alone I could still do what I want, I'd just have to be on my toes and make sure that each domain
always redirects any non-WWW URL to a WWW URL.