【问题标题】:Annoying "No input File Selected" Codeigniter (htaccess)烦人的“未选择输入文件”Codeigniter (htaccess)
【发布时间】:2011-08-23 20:25:21
【问题描述】:

我在这里看到了一个关于这个问题的类似问题,但由于它没有解决我的问题,我不得不写另一个。

我已将客户的网站从我自己的测试服务器移至他们之前购买的网站托管商 lcn.com。虽然主页 http://mydomain.com 加载非常好,但任何子页面 (http://mydomain.com/page) 都会给我“未选择输入文件”错误。

这一定是 htaccess/server 设置问题,虽然 lcn 告诉我 mod rewrite 已全部启用,并且不应限制任何内容。如果我以简单的方式访问子页面,http://mydomain.com/index.php/page,它们可以正常加载。

所以,这里是我的 htaccess 文件。有没有想过我为什么会遇到问题?

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>

ErrorDocument 404 /index.php
</IfModule>

【问题讨论】:

  • 我会看看 RewriteBase,可能是它应该类似于 /webhost/globalroot/mydomain/
  • 我以前从未将 document_path 包含在 RewriteBase 中 - 在所有主机上我遇到过一个简单的 / 或子目录都可以正常工作。反正试一试,500秒。

标签: .htaccess codeigniter


【解决方案1】:

这是原始论坛(CI论坛)中的一千次问题。虽然上面的 htaccess 通常可以从您的 url 中删除 index.php,但您需要检查/尝试几个额外的配置。

  1. 你的 htaccess。

    # RewriteRule ^(.*)$ index.php/$1 [L]
    # While above rule seems fine in general environment, sometime i need to modify that into
    RewriteRule ^.*$ index.php/$1 [L]
    
  2. 你的 config.php

    // $config['uri_protocol']  = 'AUTO';
    // In some environment, you need to change it
    // $config['uri_protocol']  = 'PATH_INFO';
    // or..
    $config['uri_protocol'] = 'REQUEST_URI';
    

【讨论】:

  • 您好 toopay - 感谢您的回复。实际上,我已经尝试了在 CI 论坛上可以找到的所有内容,但对 htaccess 或 uri 协议设置的更改没有任何帮助。您在这里的两个建议不能解决这个问题。您还有其他想法吗?
  • 在某些(奇怪的)情况/环境中,我需要添加“?”在重写规则RewriteRule ^(.*)$ index.php?/$1 [L]
  • 我试了一下(这肯定是一个奇怪的环境),奇怪的是所有页面都重定向到主页 - 这很奇怪吗?
  • 尝试将您的 uri 协议更改为 REQUEST_URI,并尝试使用上面给出的各种 htaccess...
  • 你太棒了。 REQUEST_URI + index.php?/$i (带问号)有效。最后。那是多么浪费时间啊!再次感谢。
猜你喜欢
  • 1970-01-01
  • 2013-04-08
  • 2017-07-24
  • 1970-01-01
  • 1970-01-01
  • 2012-08-15
  • 2012-06-04
  • 2019-06-05
相关资源
最近更新 更多