【问题标题】:Different content in same php同一php中的不同内容
【发布时间】:2019-05-28 08:08:11
【问题描述】:

我们如何在同一个网站的不同域中显示不同的内容?

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.net content

domain.netdomain.com 是同一服务器中的同一网站。 domain.netdomain.com 的镜像。 我需要使用php if condition blablabla吗?

【问题讨论】:

标签: php


【解决方案1】:

使用全局变量 $_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 } ?>

【讨论】:

    【解决方案2】:

    在 PHP 中:Get current domain

    在 JavaScript 中:Get current domain

    然后您可以在 PHP 或 JavaScript 中执行一些 if/else 语句并相应地显示您的内容。

    问候,

    奥马尔·阿卜杜拉

    【讨论】:

      猜你喜欢
      • 2015-09-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多