Reputation: 3073
Background
I have a little site that has been setup for our marketing team, it is configured on the same server as our core site. The site has been setup as marketing.lan
in Apache
. We have configured things so that any request made to our core site via the /marketing
url load the marketing.lan
pages. Example:
will point to the test.php
script on the marketing.lan
site. No redirection done, the browser URL will still be
www.coresite.com/marketing/test.php.
Apache is doing this by setting the host to marketing.lan for all request made via the 'www.coresite.com/marketing/' URL.
Problem
The problem is this, when I try and get the URL the page was accessed via using $_SERVER['HTTP_HOST']
I get marketing.lan/test.php
not www.coresite.com/marketing/test.php
, even with the browser showing the correct URL.
Question Is it possible to get the actual 'URL the script was accessed by? Or is this hidden by Apache? How would I do that.
Upvotes: 1
Views: 606
Reputation: 2701
Both the sites are in the same server (presumably, a Linux machine)
www.coresite.com
has a DocumentRoot
something like /var/www/coresite.com/
marketing.lan
has a DocumentRoot
something like /var/www/marketing.lan/
You now want marketing.lan
as a sub-site of www.coresite.com
such that http://www.coresite.com/marketing/ shows the contents of http://marketing.lan/
There is no need to modify their individual apache configuration; just create a symlink
.
ln -s /var/www/marketing.lan /var/www/coresite.com/marketing
This will answer your question:
If your test.php
has a line echo $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
Going to the url http://www.coresite.com/marketing/test.php
will show
www.coresite.com/marketing/test.php
Going to the url http://marketing.lan/test.php
will show
marketing.lan/test.php
Upvotes: 1