1

How do we display different content in a different domain on the same website?

example
domain.com content show this in body
*hello you are vising domain.com*

domain.net content show this in body
*hello you are vising domain.net*

.com content and .net content

But domain.net and domain.com is the same website in the same server. domain.net is a mirror from domain.com. Do I need to use php if condition blablabla?

Gerard de Visser
  • 7,590
  • 9
  • 50
  • 58

2 Answers2

0

Use the global variable $_SERVER['HTTP_HOST']

<?php if ($_SERVER['HTTP_HOST']==='domain.com') { ?>
here is the contents of domain.com
<?php else if ($_SERVER['HTTP_HOST']==='domain.net') { ?>
here is the contents of domain.net
<?php } ?>
EvE
  • 734
  • 3
  • 13
0

In PHP: Get current domain

In JavaScript: Get current domain

Then you can do some if/else statements in either PHP or JavaScript and display your content accordingly.

regards,

Umar Abdullah

Umar Abdullah
  • 1,282
  • 1
  • 19
  • 37