简体   繁体   English

CDN 链接无法使用 PHP 包括

[英]CDN link is not working using PHP include

I'm using PHP include this is working fine on my local but when I using include file as CDN like given below then it is not working.我正在使用 PHP 包含这在我的本地工作正常但是当我使用包含文件作为 CDN 时,如下所示,它不起作用。 I don't know what is wrong with it.我不知道它有什么问题。

This is working:这是有效的:

 <?php include 'include/head.php'?>

This is not working:这不起作用:

 <?php include 'http://example.com/cdn/include/head.php'?>

I need to use include as CDN because I have multiple directories and pages so I can't manage with the working example as given above.我需要使用 include 作为 CDN,因为我有多个目录和页面,所以我无法使用上面给出的工作示例进行管理。

CDN is for using JS and CSS files, not to include in your system. CDN 用于使用 JS 和 CSS 文件,不包含在您的系统中。 If you want to do that, just download and reference it from your directory.如果您想这样做,只需从您的目录下载并引用它。 The purpose for CDN is to have the proper file loaded from the closest (most likely the fastest) place served. CDN 的目的是从最近(很可能是最快)的地方加载正确的文件。

ALSO: including from an URL is only an option if you have the allow_url_include PHP.ini variable set to 1/on.另外:如果您将 allow_url_include PHP.ini 变量设置为 1/on,则仅包含来自 URL 的选项。 https://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-include https://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-include

For security reasons I won't do that and that's why it is disabled by PHP default出于安全原因,我不会这样做,这就是 PHP 默认禁用它的原因

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM