显示不同域名上站点的一页
我有一个包含 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您应该查看其中一个(按顺序):
include()
file_get_content()
并将变量打印到页面中< 简单但不安全的方法
curl
库的fopen()
的 要打开的远程文件,但根据我的经验,它不太可靠查看 这个网站,它似乎对您的问题相当详尽。
You should look at either (in order):
include()
with correct php.ini configurationfile_get_content()
and printing the variable into your page<iframe src="yoururl">
wich would be the easy peasy but unsafe waycurl
libraryfopen()
wich theorically allows distant files to be opened, but based on my experience, it's not that reliableLook at this site, it seems rather exhaustive regarding your problem.
尝试包含该文件
Try including the file
我认为你在这里需要的是一个符号链接,这是我不太了解的东西。我的理解是,向用户显示的路径实际上与文件的实际存储位置无关,这意味着您可以将其设置为具有完全不同的 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.
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 sureallow_url_include
in php.ini is enabled, as by default script execution will terminate when encoutering a remote URLinclude
statement.