carlenevs
asked on
Including a file on a page - Same page, Different URLs
Hello Everybody!
I have a situation in which I need to include a file on a single page that has 2 different URLs and path depths.
For example:
Include File: http://www.mysite.com/include/include.inc
URL 1 = http://www.mysite.com/mypage/index.php
URL 2 = http://mypage.mysite.com/index.php
I know I can include a file absolutely by using $_SERVER['DOCUMENT_ROOT'], but that does not work in the URL 2 situation (as the DOCUMENT_ROOT includes the "mypage" directory in its output, essentially then looking for the file in root/mypage/include/includ e.inc instead of root/include/include.inc).
Is there any straightforward way to overcome this? This is within a larger system using templates, so I don't have a lot of leeway in my programming.
Thanks!
Carlene
I have a situation in which I need to include a file on a single page that has 2 different URLs and path depths.
For example:
Include File: http://www.mysite.com/include/include.inc
URL 1 = http://www.mysite.com/mypage/index.php
URL 2 = http://mypage.mysite.com/index.php
I know I can include a file absolutely by using $_SERVER['DOCUMENT_ROOT'],
Is there any straightforward way to overcome this? This is within a larger system using templates, so I don't have a lot of leeway in my programming.
Thanks!
Carlene
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Wait.
So, why are the paths not relative?
Both of those URLS point to the same folder no>?
So, why are the paths not relative?
Both of those URLS point to the same folder no>?
include('http://www.mysite.com/mypage/index.php');
include('http://mypage.mysite.com/index.php');
Good luck!!