【问题标题】:Removing public/index.php?删除 public/index.php?
【发布时间】:2014-01-05 18:24:53
【问题描述】:

我们如何从 ci-bonfire 0.7 中删除 public/index.php

我看到有删除根 index.php 的说明,但我无法删除根 public/index.php 并且没有与之相关的说明。

我尝试了http://cibonfire.com/docs/bonfire/removing_index 中的说明,但没有成功。我去的时候一直收到 404

http://localhost/Bonfire-0.7/index.php

但是

http://localhost/Bonfire-0.7/public/index.php

工作正常。

【问题讨论】:

    标签: codeigniter-2 bonfire


    【解决方案1】:

    打开目录application/config/config.php 并执行以下操作:

    $config['index_page'] = '';
    

    【讨论】:

    • 我还是没有通过。该站点仍需要以http://localhost/Bonfire-0.7/public/index.php/login 访问,而不是http://localhost/Bonfire-0.7/index.php/loginhttp://localhost/Bonfire-0.7/login
    • 基本上,我无法从网址中删除public
    【解决方案2】:

    我正在使用 XAMPP + bonfire v0.7,我已经将它安装在一个名为“ci-bonfire”的子目录下,这是我的解决方案。

    删除 URL 中的 index.php

    第 1 步:转到 ci-bonfire/application/config/config.php,从索引页面配置中删除“index.php”。

    $config['index_page'] = "";
    

    第 2 步:将 ci-bonfire/public/ 中的 1.htaccess 更改为 .htaccess 更新第 #158 行,更改为您的子目录名称

    <IfModule mod_rewrite.c>
      Options +FollowSymlinks
      RewriteEngine On
      RewriteBase /ci-bonfire
      RewriteCond %{REQUEST_URI} ^bonfire/codeigniter.*
      RewriteRule ^(.*)$ /index.php?/$1 [L]
    </IfModule>
    

    再到第 182 行,将“public”添加到“index.php”

    <IfModule mod_rewrite.c>
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ public/index.php/$1 [L]
    </IfModule>
    

    删除 URL 中的 public/index.php

    第 1 步:转到 ci-bonfire/application/config/config.php,从索引页面配置中删除“index.php”。

    $config['index_page'] = "";
    

    第 2 步:重命名(出于备份目的)或删除子目录中的 index.php.htaccessci-bonfire

    第 3 步:然后参考此cibonfire's documentation 中的“恢复到传统结构”。将 public 文件夹中的所有文件向上移动 1 级到您的子目录。

    第四步:更新index.php如下

    $path = ".";
    

    希望对我有帮助:)

    【讨论】:

      【解决方案3】:

      删除远程 WebServer 中的 public/index.php(生产中)

      第 1 步: 转到 application/config/config.php,从 index-page 配置中删除“index.php”。

      $config['index_page'] = ""; (第 35 行)

      第 2 步:删除 /(根目录)中的 index.php 和 .htaccess

      第 3 步:将所有文件从 /public 文件夹移动到 /(根目录)。

      第四步:更新/中的新index.php如下

      $path = "."; (第 74 行)

      就是这样!开心点!

      【讨论】:

        【解决方案4】:

        您好,我在 CodeIgniter 中遇到了这个错误,服务器中的安装如下一个示例:

        SERVER_IP/public/index.php/controller/method

        但我需要

        SERVER_IP/控制器/方法

        我的解决方案非常简单,我的项目在根目录中,然后我进入根目录,我必须创建一个 .htaccess 文件配置。像这样:

        <IfModule mod_rewrite.c>
           RewriteEngine On
           //Setting de base URL. 
           RewriteBase /public
           RewriteCond %{REQUEST_FILENAME} !-f
           RewriteCond %{REQUEST_FILENAME} !-d
           //Setting the pattern to match 
           RewriteRule ^(.*)$ index.php/$1/ [L]
        </IfModule>
        

        最终结果是:

        请求:SERVER_IP/login => SERVER_IP/public/index.php/login

        请求:SERVER_IP/login/doLogin => SERVER_IP/public/index.php/login/doLogin

        请求:SERVER_IP/login/logout?noredirect=1 => SERVER_IP/public/index.php/login/logout?noredirect=1

        祝你好运……

        【讨论】:

          【解决方案5】:

          试试:

          IR 地毯:公共/ 转到公共文件夹/

          将 public/1.htaccess 重命名为 .htaccess

          http://cibonfire.com/docs/developer/removing_index

          编辑 .htaccess 文件并添加一个 RewriteBase 选项,指向您在第 151 到 165 行附近使用的文件夹替换。

          <IfModule mod_rewrite.c>
          Options +FollowSymlinks
          RewriteEngine On
          RewriteBase /public
          

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2017-09-28
            • 2017-01-03
            • 1970-01-01
            • 2019-12-27
            • 2019-08-31
            • 2014-07-13
            • 2019-04-02
            • 2018-06-30
            相关资源
            最近更新 更多