duanliang8464 2013-11-13 16:11
浏览 125


I have two urls - biothoughtblog.co and playfight.co. The first is forwarding to the second and masking is used. I am using this

function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
 } else {
 return $pageURL;

  echo curPageURL();

on the page http://www.biothoughtblog.co/test.php - however, it echoes the real URL which is http://www.playfight.co/test.php. I need it to echo the URL that is in the address bar. I know very very little Javascript - is it what I need to be using here?

Thanks a lot.

P.S Oh, and the purpose is to run the same website under two different domains and different branding (logo, etc).

  • 写回答

2条回答 默认 最新

  • douwen7475 2013-11-13 16:13

    That's because http://www.biothoughtblog.co/test.php is framing http://www.playfight.co/test.php.

    <frame src="http://www.playfight.co/test.php" frameborder="0" />

    PHP has no way of knowing that it is loaded inside a frameset, and how to get the URL of the parent frame.

    You want to avoid using the "masking" feature of your registrar or DNS provider. Point the biothoughtblog.co domain to the same hosting server, ensure that your hosting account is setup for both domains. Then biothoughtblog.co wil be hitting your website directly, and PHP will know what it is.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
  • duanrang2627 2013-11-13 16:31

    You don't need to do anything in PHP to run the same website under two different domains.

    If you are using apache, open your conf file, locate your virtual host config and add a serverAlias.


    <VirtualHost *:80>
        DocumentRoot "/var/www/html"
        ServerName biothoughtblog.co
        ServerAlias playfight.co
        <Directory "/var/www/html">
            AllowOverride All



  • ¥15 jsp,如何使用户名输出为中文(语言-javascript)
  • ¥20 文件读写,但中文乱码
  • ¥15 PowerBI中如何做到按数值向下取数
  • ¥15 设计quartus maxⅡ :Verilog-FPGA(0
  • ¥15 windows server 2022 datacenter安全策略配置 没有权限问题
  • ¥20 寻找dspace有偿技术支持
  • ¥30 深度学习的模型融合问题
  • ¥20 数电实验Verilog编程
  • ¥15 机器人MATLAB仿真示教占内存过大
  • ¥15 JSR233已经使用但是仍无法将csv数据放到一个list里显示出来,如何解决?