dongzhangnong2063 2012-10-11 21:23
浏览 177

.htaccess与^(。*)$ index.php / $ 1给出“未指定输入文件”

I'm running Code Igniter and my .htaccess was:

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

Then I realized that no $_GET variable was getting through.

I followed some instructions to create the .htaccess to use together with Code Igniter, and replaced the index.php?$1 with index.php/$1. This works on a linux machine, but on the Windows it doesn't. I'm sure it is a server configuration, but I don't know which one.

Assuming that I access

http://localhost/directory/this_is_query/string_parameters?with_some=additional_ones

The $_SERVER['QUERY_STRING'] value with index.php?$1 on .htaccess is:

string(31) "this_is_query/string_parameters" 

And with index.php/$1:

No input file specified. 

On the Linux machine I have:

string(31) "with_some=additional_ones"

As response with index.php/$1.

Any thoughts?


I'm debugging the $_SERVER['QUERY_STRING'] variable on the FIRST line of index.php, with NO interaction with Code Igniter whatsoever.

Yes, I do have mod_rewrite.

THIS IS NOT THE SAME AS Codeigniter no input file specified error

I saw that question before asking this one. And I'm still with the issue.

I've added new information.

  • 写回答

2条回答 默认 最新

  • doucigua0449 2012-10-11 21:29
    关注

    I think you're missing the QSA option to append the query string to the end:

    RewriteRule \.svn/ - [F,L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?$1 [L,QSA]
    

    And to keep query params organized, I would suggest setting a parameter name, if allowed with CodeIgniter:

    RewriteRule ^(.*)$ index.php?page=$1 [L,QSA]
    
    评论

报告相同问题?

悬赏问题

  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?