代码之家  ›  专栏  ›  技术社区  ›  Michal M

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

  •  39
  • Michal M  · 技术社区  · 16 年前

    有人能帮我吗?我觉得我的头撞到墙上已经两个多小时了。

    我已经得到 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]
    

    宿主提供程序服务器上的相同代码为我提供404错误代码和输出 only: No input file specified. index.php就在那里。我知道他们已经安装了Apache(在任何地方都找不到版本信息),并且他们正在运行php v5.2.8。

    我在 Windows XP 64-bit ,他们正在运行一些 Linux 具有 PHP 在里面 CGI/FastCGI 模式。有人能提出什么问题吗?

    如果这很重要,那是为了 CodeIgniter 使用友好的URL。


    更新1:

    mod_rewrite 已安装并打开。

    我注意到如果我换了 RewriteRule /index.php?$1 (问号而不是正斜杠)它进入无限循环。无论如何,使用问号不是一个选项 密码点火器 (必需)不会以这种方式工作。

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

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


    更新2:

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


    更新3:

    只是想弄清楚我想要达到的目标。
    我想重写这样的地址:

    http://www.example.com/something/ = & gt; http://www.example.com/index.php/something/ http://www.example.com/something/else/ = & gt; http://www.example.com/index.php/something/else/

    12 回复  |  直到 8 年前
        1
  •  84
  •   jray    16 年前

    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]
    
        2
  •  27
  •   Ynhockey    8 年前

    • RewriteBase /

    https://ellislab.com/forums/viewthread/55620/P15

    RewriteRule ^(.*)$ index.php/$1
    

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

        3
  •  9
  •   cdomination    10 年前

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

    index.php

        4
  •  4
  •   kkyy    16 年前

    RewriteCond

    RewriteEngine on
    
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    
    RewriteRule ^(.*)$ /index.php/$1 [R,L]
    
        5
  •  4
  •   slm Vikas Hardia    13 年前

        6
  •  3
  •   Jay Paroline    16 年前

    mod_rewrite

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

        7
  •  1
  •   Paradise of Creativity    8 年前

    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]
    

    RewriteEngine On
    #RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule (.*) index.php/$1
    
        8
  •  0
  •   Community Mohan Dere    9 年前

    Server Fault

    RewriteCond $1 !^(index\.php|css|gfx|js|swf|robots\.txt|favicon\.ico)
    

    www.yourdomain.com/index.php/something www.yourdomain.com/js/something

    RewriteCond $1 !^(index\.php|css|gfx|js|swf|robots\.txt|favicon\.ico)$
    
        9
  •  0
  •   Johan    13 年前

    no input file specified

    RewriteRule ^(.*\.swf)$  redirect_php.php/?a=1 [last]
    

    RewriteRule ^(.*\.swf)$  redirect_php.php?a=1 [last]
    

    / ?

    http://domain.com/file.php/tricky_path/?regular_query_stuff
    
        10
  •  0
  •   halfpastfour.am    9 年前


        11
  •  0
  •   Yevgeniy Afanasyev    8 年前

    echo $_SERVER["SERVER_SOFTWARE"];
    
        12
  •  -1
  •   Gumbo    16 年前

    AcceptPathInfo

    AcceptPathInfo On
    

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule !^index\.php(/|$) index.php%{REQUEST_URI} [L]
    
    推荐文章