首页 > 解决方案 > 代码点火器 | 将 index.php 移至公用文件夹

问题描述

我是 CodeIgniter 的新手,我认为可以尝试一下

  1. 下载了 CodeIgniter 中可用的代码
  2. 将基本网址更改为$config['base_url'] = 'http://localhost:8000';
  3. 使用命令启动服务器php -S 0.0.0.0:3000

这很顺利。接下来,我尝试将index.php文件移动到公共文件夹中——这就是事情开始破裂的时候。

  1. 将 index.php 移至新创建的公用文件夹
  2. 使用以下代码片段创建了一个新文件 public/.htaccess

    RewriteEngine on
    RewriteCond $1 !^(index\.php|assets|images|js|css|uploads|favicon.png)
    RewriteCond %(REQUEST_FILENAME) !-f
    RewriteCond %(REQUEST_FILENAME) !-d
    RewriteRule ^(.*)$  ./index.php/$1 [L] 
    
  3. 修改$system_path = '../system';$application_folder = '../application'; 在public/index.php.

  4. 404 Resource not found当我在重新启动服务器后尝试访问该页面时,我得到一个,。

标签: phpcodeignitercodeigniter-3

解决方案


您是否更改了服务器配置中的根文件夹?

如果您将 index.php 移动到不同的文件夹,您应该在服务器设置中更改了 index.php 的路径。在配置文件中。


推荐阅读