.htaccess问题:未指定输入文件

Mic*_*l M 41 php apache .htaccess codeigniter

有人可以帮我弄这个吗?我觉得我现在已经在墙上撞了两个多小时了.

我已经Apache 2.2.8 + PHP 5.2.6安装在我的机器上,.htaccess下面的代码工作正常,没有错误.

RewriteEngine on
RewriteCond $1 !^(index\.php|css|gfx|js|swf|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ /index.php/$1 [L]
Run Code Online (Sandbox Code Playgroud)

我的托管服务提供商服务器上的相同代码给我一个404错误代码并输出only: No input file specified.index.php就在那里.我知道他们安装了Apache(无法在任何地方找到版本信息),他们正在运行PHP v5.2.8.

我在Windows XP 64-bit,他们正在运行的一些LinuxPHPCGI/FastCGI模式.任何人都可以建议可能是什么问题?

PS.如果重要的是CodeIgniter使用友好的URL.


UPDATE1:

mod_rewrite 安装并打开.

我注意到的是,如果我RewriteRule改为/index.php?$1(问号而不是正斜杠),它会进入无限循环.无论如何,使用问号不是一个选项,因为CodeIgniter(必需)不会以这种方式工作.

当我直接请求index.php时,主页也可以使用: example.com/index.php

我开始认为可能是apache认为一旦添加了斜杠,它就不再是一个文件了,而是一个文件夹.如何改变这种行为?


更新2:

我错了.
Apache正确处理这些URL.
请求http://example.com/index.php/start/(主页)或任何其他有效地址有效.
似乎Apache只是因为某种原因没有转发查询.


更新3:

只是为了清楚我想要实现的目标.
我想重写这样的地址:

http://www.example.com/something/ => http://www.example.com/index.php/something/ http://www.example.com/something/else/ => http:// www.example.com/index.php/something/else/

jra*_*ray 85

我也在反对这一点.我也在安装Code Igniter.

goocher不是RewriteBase.这是我的.htaccess:

DirectoryIndex index.php

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt)

RewriteRule ^(.*)$ index.php?/$1 [L]
Run Code Online (Sandbox Code Playgroud)

  • 我已经有一个“RewriteBase”,但为我解决的是最后一个“RewriteRule”上“index.php”之后的“?”。这是基于 Plesk 面板的服务器,通过 fastcgi 运行 apache/php。 (2认同)

Ynh*_*key 27

问题

我刚才遇到了类似的问题,不幸的是,这个帖子中的答案都没有帮助:

Zend Framework发布了"未指定输入文件.",但是:

  • 默认的RewriteBase很好,添加RewriteBase /没有帮助
  • 它是一个共享托管服务器,只有FastCGI可用(无法切换到SuPHP)
  • AcceptPathInfo已启用
  • 一般在服务器上进行URL重写没有问题

因此,答案来自于以下站点: https://ellislab.com/forums/viewthread/55620/P15 [死链接(即使主机不是DreamHost的).

解决方案

显然你需要做的就是替换这一行:

RewriteRule ^(.*)$ index.php/$1
Run Code Online (Sandbox Code Playgroud)

有了这个:

RewriteRule ^(.*)$ index.php?/$1
Run Code Online (Sandbox Code Playgroud)

问题解决了.


A.G*_*AYS 9

这对我有用:

 <IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L]
 </IfModule>
Run Code Online (Sandbox Code Playgroud)

之后index.php,问号很重要!