.htaccess问题:未指定输入文件 [英] .htaccess issues: No input file specified
问题描述
有人可以帮我吗?我感觉好像已经将我的头撞在墙上超过2个小时了.
Can someone help me with this? I'm feeling like I've been hitting my head against a wall for over 2 hrs now.
我已经在计算机上安装了Apache 2.2.8 + PHP 5.2.6
,并且带有以下代码的.htaccess
可以正常工作,没有错误.
I've got Apache 2.2.8 + PHP 5.2.6
installed on my machine and the .htaccess
with the code below works fine, no errors.
RewriteEngine on
RewriteCond $1 !^(index\.php|css|gfx|js|swf|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ /index.php/$1 [L]
我的托管服务提供商服务器上的相同代码给了我404错误代码,并输出了only: No input file specified.
index.php.我知道他们已经安装了Apache(无法在任何地方找到版本信息),并且它们正在运行PHP v5.2.8.
The same code on my hosting provider server gives me a 404 error code and outputs only: No input file specified.
index.php is there. I know they have Apache installed (cannot find version info anywhere) and they're running PHP v5.2.8.
我在Windows XP 64-bit
上,他们正在CGI/FastCGI
模式下使用PHP
运行一些Linux
.谁能建议可能是问题所在?
I'm on Windows XP 64-bit
, they're running some Linux
with PHP
in CGI/FastCGI
mode. Can anyone suggest what could be the problem?
PS.如果那很重要,那么CodeIgniter
可以使用友好的URL.
PS. if that's important that's for CodeIgniter
to work with friendly URLs.
Update1:
Update1:
mod_rewrite
已安装并打开.
我注意到的是,如果我将RewriteRule
更改为/index.php?$1
(问号而不是正斜杠),则会陷入无限循环.无论如何,不能使用问号,因为CodeIgniter
(必填)不会以这种方式工作.
What I've noticed is that if I change in RewriteRule
to /index.php?$1
(question mark instead of forward slash) it goes into an infinite loop. Anyway, using question mark isn't an option as CodeIgniter
(required) is not going to work this way.
当我直接请求index.php时,主页也可以使用:example.com/index.php
Homepage also works when I request index.php directly: example.com/index.php
我开始认为这可能是一种apache,认为一旦添加了斜杠,它就不再是文件而是文件夹.如何改变这种行为?
I'm starting to think it might be apache thinking that once the trailing slash is added it is not a file anymore but a folder. how to change such a behaviour?
更新2:
我错了.
Apache可以正确处理这些URL.
请求http://example.com/index.php/start/
(主页)或任何其他有效地址.
似乎Apache
出于某种原因而没有转发查询.
I was wrong.
Apache handles these URLs correctly.
Requesting http://example.com/index.php/start/
(homepage) or any other valid address works.
Seems that Apache
is just not forwarding the query for some reason.
更新3:
只是要弄清楚我要实现的目标.
我想这样重写地址:
Just to be clear what I'm trying to achieve.
I want to rewrite addresses like that:
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/
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/
推荐答案
我也很反对这一观点.我也在安装Code Igniter.
I was beating my head up against this as well. I'm also installing Code Igniter.
古怪的人不是RewriteBase.这是我的.htaccess:
The goocher was no RewriteBase. Here's my .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]
这篇关于.htaccess问题:未指定输入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!