2013-10-16 42 views
0

我已經有喜歡顯示另一頁的內容,而無需更改URL

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

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

請幫助。

+0

.htaccess mod rewrite。在這裏:http://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/ – bksi

+0

看到:http://stackoverflow.com/questions/13896810/hide-url-directory/13896864# 13896864 – bksi

回答

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; 
?> 

讓我知道這是否適合你。

+0

如果他沒有訪問.htaccess或沒有mod_rewrite,這是一種解決方案。但是如果他有權訪問.htaccess並且有mod_rewrite,這不是一個好的解決方案 – bksi

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

這將導入頁面的所有內容。如果session_start()被多次調用,您也可以使用「include_once」而不是「include」。

同樣,

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

「要求」停止加載頁面的其餘部分,如果沒有找到該文件,而「包括」不停止。

相關問題