Reputation: 41
I currently run two domains on the same server. Both websites use the same files.
Is it possible to utilize javascript or jquery or something else to display certain page content based on which domain the user is accessing from?
For example. If user arrives from "www.site1.com" can I make the page display a different css template than if they access from "www.site2.com".
I hope this makes sense. Thanks.
Upvotes: 4
Views: 2659
Reputation: 3059
You can check the $_SERVER['HTTP_REFERER']
value to try to learn where from your user has came (it has nothing to do with the domain name of application he has came to). This value might be useful but you shouldn't depend on it, because it can be easily changed (it's one of the headers web browser may set when following a link).
Upvotes: -1
Reputation: 787
use $_SERVER['SERVER_NAME']
and you can also check $_SERVER variable
var_dump($_SERVER);
Upvotes: 0
Reputation: 1522
In PHP: Get current domain
In JavaScript: Get The Current Domain Name With Javascript (Not the path, etc.)
Then you can do some if/else statements in either PHP or JavaScript and display your content accordingly.
Upvotes: 2