2

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.

Community
  • 1
  • 1
dmmd
  • 2,938
  • 4
  • 33
  • 41
  • Try `$_SERVER['PATH_INFO']` when using index.php/$1. – Madara's Ghost Oct 11 '12 at 21:29
  • With index.php/$1 I also get 'No input file specified' on PATH_INFO. – dmmd Oct 11 '12 at 21:30
  • Yes, it is similar to that one, but not the same. I need to keep both my linux and windows machines with the same .htaccess. And on linux, the /$1 works perfectly. And also, I'm testing this without Code Igniter, so it's not a CI configuration issue. – dmmd Oct 11 '12 at 21:38

2 Answers2

1

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]
Matt S
  • 14,976
  • 6
  • 57
  • 76
1

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

clickme please
  • 207
  • 4
  • 9
  • 20
  • I need to use index.php/$1, as this should be the same on both Linux and Windows. Can you please help me to reopen this question? Cheers :) – dmmd Oct 15 '12 at 14:54