Codeigniter将 index.php 文件转移到新建 public 下的方法

栏目: PHP · 发布时间: 8年前

内容简介:Codeigniter将 index.php 文件转移到新建 public 下的方法

…众所周知的原因。目前很多网站框架都已经把入口文件置于”public” 等目录下了。这样做的好处,保证了网站的整体安全性的问题。

CI3,目前对于官方来说,应该已经算是逐步放弃的了。官方目前正在开发 CI4,基于现代流行的框架,所以 CI3的在使用人群中已经不占优了。

但是对于我来说,我还是比较喜欢CI3这种简单不复杂的框架的,目前好几个项目都是使用 CI3。当然,也是要考虑换一种现代流行的框架了。

言归正传。

在根目录下新建一个文件夹 public,并将 index.php 文件转移进来。以及一些静态文件也要转移进来。(如访问网站时 xxx/static/xxx.js,将 static 也转移进来)

修改 index.php 文件的内容:

$system_path = 'system';  改为 $system_path = '../system';
$application_folder = 'home';  改为  $application_folder = '../home';
define('FCPATH', dirname(__FILE__).DIRECTORY_SEPARATOR);  改为   define('FCPATH', dirname(__DIR__).DIRECTORY_SEPARATOR);

并将 nginx 的 conf 配置文件的 root 路径映射到 public,重启 nginx ,使配置文件生效即可。

请参考 API 集市: https://www.apijs.cc


以上所述就是小编给大家介绍的《Codeigniter将 index.php 文件转移到新建 public 下的方法》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Traction: A Startup Guide to Getting Customers

Traction: A Startup Guide to Getting Customers

Gabriel Weinberg、Justin Mares / S-curves Publishing / 2014-8-25 / USD 14.99

Most startups end in failure. Almost every failed startup has a product. What failed startups don't have is traction -- real customer growth. This book introduces startup founders and employees to......一起来看看 《Traction: A Startup Guide to Getting Customers》 这本书的介绍吧!

MD5 加密
MD5 加密

MD5 加密工具

SHA 加密
SHA 加密

SHA 加密工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换