0

I uploaded my code files to example1.com and pointed another domain example2.com also to example1.com, both are showing the same content now.

Now I need to have a condition to make changes according to the domain that is being requested. How can I get it in PHP, I have seen the values in $_SERVER variable, but it couldn't help.

MZaragoza
  • 10,108
  • 9
  • 71
  • 116
Aditya Vijay
  • 231
  • 2
  • 13

3 Answers3

0

try this out

$ref=$_SERVER['HTTP_REFERER'];

Reference

Community
  • 1
  • 1
  • this is working, I found it in $_SERVER, but it is not that we shouldn't use HTTP_REFERER, as this can be manipulated? – Aditya Vijay Apr 14 '15 at 09:59
  • this is problematic, if I go through both the site concurrently, it shows the weird behaviour as this gives the last page viewed. – Aditya Vijay Apr 15 '15 at 06:41
0

you can Use $_SERVER['HTTP_HOST'] and $_SERVER['SERVER_NAME']

$_SERVER['HTTP_HOST'] --> 'localhost:8080' $_SERVER['SERVER_NAME'] --> 'localhost'

Siamand
  • 1,080
  • 10
  • 19
0

Try this, i have tried in this above domain name then domain name is displayed .

Code:-

<?php
echo "Server Name:".$_SERVER['SERVER_NAME']."</br>";
echo "Domain Name:".$_SERVER['HTTP_HOST'];
?>

Output:-

  Server Name:  codepad
  Domain Name:  codepad.viper-7.com

Here codepad is a server name and codepad.viper-7.com is domain name.

Click here and check once.Reference Example

RaMeSh
  • 3,330
  • 2
  • 19
  • 31