0

我已经有类似的页面

http://example.com/page1
http://example.com/page2
http://example.com/page3

我需要在以下子域上加载这些页面

http://page1.example.com/
http://page2.example.com/
http://page3.example.com/

它应该像http://page1.example.com/一样工作,应该加载http://example.com/page1的内容,而不改变浏览器地址栏中的 URL

我使用了以下代码,但它改变了浏览器地址栏中的 URL

header('Location: http://example.com/page1'); 

请帮忙。

4

2 回答 2

0

尝试这个。这有点像黑客:

// Just add the below few lines of code in your subdomain page - http://page1.example.com/
<?php
$content = file_get_contents('http://example.com/page1');
echo $content;
?>

让我知道这是否适合您。

于 2013-10-16T04:56:38.770 回答
0
<?php
include 'http://example.com/page1';
?>

这将导入页面的所有内容。如果 session_start() 被多次调用,您也可以使用“include_once”而不是“include”。

相似地,

<?php
require 'http://example.com/page1';
?>

如果找不到文件,“require”会停止加载页面的其余部分,而“include”不会停止。

于 2013-10-16T05:19:06.673 回答