4

Here I have .htaccess file with:

Options +FollowSymLinks

RewriteEngine on

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule .* index.php [QSA,L]

And rewriting works but there is no path_info in my index.php when I'm trying http://site.com/example .

I have red this topic https://stackoverflow.com/questions/1442854/codeigniter-problem-with-mod-rewrite-on-apache-1-3 but it didn't solve my problem.

So, this issue happens only on apache 1.3 (on 2.0 all is ok) and I wanna know why. I also unfortunately have no access to httpd.conf (

Please, help me.

Community
  • 1
  • 1
John Smith
  • 51
  • 1
  • 4
  • If you `var_dump($_SERVER);`, does anything contain what you want? In particular, what does `$_SERVER['REQUEST_URI']` contain? – DaveRandom Dec 13 '11 at 23:04
  • Yes, there is REQUEST_URI and I build my own path info from it. But I'm just trying to realize other decisions. – John Smith Dec 14 '11 at 16:03

3 Answers3

5

Try changing your rewrite rule to:

RewriteRule (.*) index.php [QSA,L,E=PATH_INFO:/$1]
DaveRandom
  • 87,921
  • 11
  • 154
  • 174
  • You just forgot the [colon between `PATH_INFO` and `/$1`](http://httpd.apache.org/docs/current/rewrite/flags.html#flag_e), of cause it crashes. I will quickly edit it... – Matteo B. Jul 27 '12 at 11:25
1

This is related to mod_negotiation and being able to access /index.php as /index (without the extension).

Solution:

a2dismod negotiation

service apache2 restart
Aliaksei Kliuchnikau
  • 13,589
  • 4
  • 59
  • 72
0

The PATH_INFO is a virtual path suffix after the real CGI executable / PHP script filename.
You need to pass one to see it:

RewriteRule (.*) index.php/$1 [QSA,L]

Note that you also might require the option to be enabled first: http://httpd.apache.org/docs/2.2/mod/core.html#acceptpathinfo

AcceptPathInfo On

And then depending on the PHP SAPI, you might have to configure the php.ini, regarding the --cgi-force-redirect setting (which is designed to eschew PATH_INFO exploits for some setups). http://php.net/manual/en/security.cgi-bin.php

mario
  • 144,265
  • 20
  • 237
  • 291
  • I tried RewriteRule (.*) index.php/$1 [QSA,L] before, no success. AcceptPathInfo On - this option was added in apache 2 as I know, but my is 1.3 and I cannot upgrade it. If trying to go site.com/index.php/example - path info will appear. – John Smith Dec 14 '11 at 16:09