【问题标题】:Htaccess not working in CodeigniterHtaccess 在 Codeigniter 中不起作用
【发布时间】:2014-03-14 06:33:57
【问题描述】:

我在我的项目中使用 tank auth。在我的本地主机中,它工作正常。但是当我将项目上传到服务器时,我收到了错误

没有指定输入文件。

我知道这是因为 htaccess。我的网址就像http://example.org/project/test/tankauth/。当我给出这个 url 时,它会重定向到 http://example.org/project/test/tankauth/index.php/auth/login 并出现错误。但是,如果我尝试使用http://example.org/project/test/tankauth/index.php?/auth/login 之类的网址,它将正常工作。

我的htaccess文件如下图:

RewriteEngine on
RewriteBase /tankauth/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

我不擅长htaccess。

【问题讨论】:

  • 检查 mod_rewrite 是否启用?
  • $config['index_page'] = 'index.php';更改为$config['index_page'] = '';

标签: php .htaccess codeigniter tankauth


【解决方案1】:

我假设你在这个上使用 apache,我还假设你没有对 apache 配置 /etc/apache2/ 进行任何更改,最后我假设你可以访问你的服务器,那么如果是这种情况,您可能需要检查http://httpd.apache.org/docs/2.2/mod/core.html#allowoverride

在您的 /etc/apache2/sites-available/default 中,您会发现

<Directory /path/to/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None <---change None to FileInfo or All
Order allow, deny
allow from all
</Directory>

然后重置你的 apache -> service apache2 restart or sudo service apache2 restart

提醒使用AllowOverride All 可能会标记一些严重的漏洞问题,如果这是生产服务器,我建议您不要使用它。

希望对你有帮助,干杯!

【讨论】:

    【解决方案2】:

    试试这个(更改最后一行)

    RewriteRule ^(.*)$ index.php/$1 [QSA,L]
    

    在 application/config/config.php 中

    $config['uri_protocol']         ="PATH_INFO";
    

    【讨论】:

      【解决方案3】:

      这是工作。

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

      【讨论】:

        猜你喜欢
        • 2014-12-23
        • 2015-04-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-03-07
        • 2018-08-07
        • 2017-08-27
        相关资源
        最近更新 更多