I am sorry if this question was already asked, but I do not know how to frame it differently - none of my searches found something that answers this.

I am currently using Windows 11 and XAMPP, with Apache 2.4.x and PHP 8.1.x, but the solution I am looking for will eventually run on a Linux (Ubuntu) server using same Apache and PHP versions.


I have two web addresses, say, https://test1.com and https://test2.com set up on my Windows Host file, that redirects to http://localhost/testapp at the moment, which is a local PHP application.

Our goal is to have a session or flag or something set when you enter testapp from either domain, so that I have that information available within the PHP application. Since the redirect happens before we even get to PHP, I suspect the place to do this would be in Apache, and I would need to set and then retrieve the value of a $_SERVER variable for the info, or something similar.

How can I achieve this? Can it be achieved?

  • Like $_SERVER['SERVER_NAME']? 35 mins ago
  • SERVER_NAME becomes something else. It does not contain test1.com or test2.com. 32 mins ago
  • Well, if you actually redirect you will only have the referrer on the first request. 30 mins ago
  • If you fell for the common misconception that a reverse proxy is a redirect (your actual config would be helpful for clarifications) you only need to configure apache to set the X-FORWARDED-FOR header. 28 mins ago
  • I do not have a reverse proxy. I don't even really know what it means. I will look into X-FORWARDED-FOR header. Thanks. 26 mins ago


You must log in to answer this question.

Browse other questions tagged .