Re: How do I link to the root directory of the server?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You could just use relative links, or use a full path link, without the
http://www.mydomain.com part.

Or, you could change application.php to use data from $_SERVER to figure
out what URL you should be using.

<?php var_dump($_SERVER);?>

and pick through that data.

Somewhere in there you will find what you need to set up $CFG->wwwrot and
$CFG->dirroot so that they always work, no matter what server you are on.


On Thu, May 5, 2005 5:01 am, Shaun said:
> Hi,
>
> I have a file called application.php and in this file I define all of the
> directories in my site:
>
> class object {};
> $CFG = new object;
>
> $CFG->wwwroot = http://www.mydomain.com;
> $CFG->dirroot      = "/usr/home/myaccount/public_html";
>
> $CFG->admindir         = "$CFG->wwwroot/admin";
> $CFG->claimsdir_adm     = "$CFG->admindir/claims";
> $CFG->clientsdir       = "$CFG->admindir/clients";
> $CFG->cssdir         = "$CFG->wwwroot/css";
> $CFG->expense_categoriesdir = "$CFG->admindir/expense_categories";
> $CFG->projectsdir       = "$CFG->admindir/projects";
> $CFG->shoppingdir      = "$CFG->wwwroot/shopping";
> ...
>
> This works very well and means if I change a directory name or move a
> directory I only have to update this file. application.php is included on
> every page so all I have to do to link to another directory would be
> something like:
>
> <p>Click <a href="<?php echo $CFG->expense_categoriesdir;
> ?>?action=add_expense_category">here</a> to add a category</p>
>
> The problem with this is that the URL's include the
> http://www.mydomain.com/
> and are therefore not relative links. Is there a way to link to the root
> directory from wherever I am within the directory structure?
>
> Thanks for your advice
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux