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
,他们正在运行的一些Linux
与PHP
在CGI/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)
Ynh*_*key 27
问题
我刚才遇到了类似的问题,不幸的是,这个帖子中的答案都没有帮助:
Zend Framework发布了"未指定输入文件.",但是:
RewriteBase /
没有帮助因此,答案来自于以下站点: 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)
问题解决了.
这对我有用:
<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
,问号很重要!
归档时间: |
|
查看次数: |
75599 次 |
最近记录: |