开发者

display one page from a site on a different domain name

I have a site complete with CMS etc all working under one domain name. It turns out for legal reasons one page on this site has to sit on a different domain name. The page is hooked into the same CMS as t开发者_如何学运维he rest of the site (built using codeigniter). I don't want to have to do another installation just for this page.

Is there any simple way to display just this page under a different domain name without taking it out of the current application?

Thanks a lot


You should look at either (in order):

  • an include()with correct php.ini configuration
  • a file_get_content() and printing the variable into your page
  • an <iframe src="yoururl"> wich would be the easy peasy but unsafe way
  • using the on-purprose curllibrary
  • using fopen() wich theorically allows distant files to be opened, but based on my experience, it's not that reliable

Look at this site, it seems rather exhaustive regarding your problem.


Try including the file

<?php include 'http://www.domain.com/url/to/file/page.html' ?>


I think what you need here is a symlink, which is something I don't know too much about. My understanding is that the path displayed to the user does not in fact have to have anything to do with where the file is actually stored, meaning you can set this up to have a completely different URL while keeping it as part of your original application.

A simpler thing is doing a redirect...it's one line of code in your .htaccess file and you're good to go.


include is a possible solution depending on the format of the remote page (ie, this won't work very well if the remote page has a full DOM structure, and you're trying to include the remote page within the DOM structure of your CMS page), however more information about that remote page would be needed to help determine if include() alone would be enough.

Regardless, if include() does, work, you must make sure allow_url_include in php.ini is enabled, as by default script execution will terminate when encoutering a remote URL include statement.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜