Posted by Aaron Saray on 10/02/07 04:37
On Oct 1, 7:53 am, artev <mailnotspa...@notspamm.nn> wrote:
> I explained better my problem (localhost in production will be NAMESITE)
> If I am inhttp://localhost/A/test.php
>
> I want in php a code (or function) that print:http://localhost/A/
>
> so it recognize automatically the url
>
> I tested functions:
> HTTP_HOST but print only localhost
> SERVER_NAME but print only localhost
> PHP_SELF not print all and insert also file's name (I not want)
> /A/test.php
>
> dirname($HTTP_SERVER_VARS['PHP_SELF']); not print all /A
>
> I can write so (semplified the merge):
> http:// + SERVER_NAME + dirname PHP_SELF
> but remain problems that I must know when I am in https so I can change
> the first part http in https;
>
> and is better use SERVER_NAME or HTTP_HOST for recognize SITE (localhost)
>
> is there a function that to do all?
What if you did this:
function getBaseUrl()
{
if (empty($_SERVER['HTTPS'])) {
//means its either not set or has no value - this will be
populated if its an SSL request
$url = 'http://';
}
else {
$url = 'https://';
}
$url .= dirname($_SERVER['REQUEST_URI']);
}
I wonder if that will work?
[Back to original message]
|