显示不同域名上站点的一页

发布于 2024-11-19 10:17:42 字数 186 浏览 0 评论 0原文

我有一个包含 CMS 等的网站,所有这些都在一个域名下运行。事实证明,出于法律原因,该网站上的一个页面必须位于不同的域名上。该页面与网站的其余部分连接到相同的 CMS(使用 codeigniter 构建)。我不想只为此页面进行另一次安装。

有没有什么简单的方法可以在不同的域名下仅显示此页面而不将其从当前应用程序中取出?

多谢

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 the 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

千纸鹤 2024-11-26 10:17:42

您应该查看其中一个(按顺序):

  • 具有正确 php.ini 配置的 include()
  • file_get_content() 并将变量打印到页面中
  • < 简单但不安全的方法
  • 专用 curl 库的
  • ;iframe src="yoururl"> 这将是使用理论上允许的 fopen() 的 要打开的远程文件,但根据我的经验,它不太可靠

查看 这个网站,它似乎对您的问题相当详尽。

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.

梦回旧景 2024-11-26 10:17:42

尝试包含该文件

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

Try including the file

<?php include 'http://www.domain.com/url/to/file/page.html' ?>
离旧人 2024-11-26 10:17:42

我认为你在这里需要的是一个符号链接,这是我不太了解的东西。我的理解是,向用户显示的路径实际上与文件的实际存储位置无关,这意味着您可以将其设置为具有完全不同的 URL,同时将其保留为原始应用程序的一部分。

更简单的事情是进行重定向...它是 .htaccess 文件中的一行代码,您就可以开始了。

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.

回忆那么伤 2024-11-26 10:17:42

include 是一个可能的解决方案,具体取决于远程页面的格式(即,这不会很有效)好吧,如果远程页面具有完整的 DOM 结构,并且您正在尝试将远程页面包含在 CMS 页面的 DOM 结构中),但是需要有关该远程页面的更多信息来帮助确定是否<单独使用 code>include() 就足够了。

无论如何,如果 include() 确实有效,您必须确保 php.ini 中的 allow_url_include 已启用,因为默认情况下脚本执行将在遇到远程 URL 时终止include 语句。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文