You are here: Re: identify by php the path of the page « All PHP « IT news, forums, messages
Re: identify by php the path of the page

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?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация