【问题标题】:Codeigniter - no input file specified - Why "?" solves this?Codeigniter - 没有指定输入文件 - 为什么是“?”解决这个?
【发布时间】:2018-02-18 10:09:12
【问题描述】:

我对消息no input file specified 有疑问。

我在 stackoverflow 的主题上找到了解决这个变化的方法

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

在 index.php 后添加问号

它奏效了。

一切看起来像:

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

但是为什么这有效?在index.php 之后添加的问号实际上是什么意思?为什么这会让一切正常?

我一直在寻找和搜索有关此类所有主题的答案,但没有找到任何可以回答我问题的内容。

我只发现它 probably 有效并且是必需的,因为 index.php 不在根目录中,但我不确定。

我的目录如下:

/ (root folder)
--->application (app folder of framework)
--->myDomain.dx.am (my domain folder)
-------->index.php
-------->.htaccess (htaccess here)
-------->other_files
...................
--->system (system folder of framework)

我只寻求这个答案,我很好奇,我想知道为什么会这样以及如何工作?

【问题讨论】:

  • 您可能需要使用“Apache”进行标记,以便具有良好 Apache 经验的人会告诉您,但这一切都归结为服务器配置,甚至可能是服务器正在使用的特定 Apache 版本。

标签: php .htaccess codeigniter mod-rewrite


【解决方案1】:

请按以下步骤操作:

  1. 转到应用程序/config/config.php: 将$config['index_page'] = 'index.php'; 替换为$config['index_page'] = '';$config['uri_protocol'] = 'REQUEST_URI';$config['uri_protocol'] = 'AUTO';

  2. 通过
    sudo a2enmod rewrite启用重写模式 然后 service apache2 restart

  3. 如果您愿意,可以使用以下 .htaccess 文件。

<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>

【讨论】:

    猜你喜欢
    • 2011-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-12
    • 1970-01-01
    • 1970-01-01
    • 2021-11-22
    相关资源
    最近更新 更多