sergtk
sergtk

Reputation: 10974

Something rewrites rules for php when Apache mod_rewrite module is disabled

I run the following url:

http://localsite/index.php/foo/bar

index.php is executed and outputs variable:

$_SERVER[SCRIPT_FILENAME] = E:/path/to/file/index.php

mod_rewrite in Apache is disabled.

Who rewrites the rule?
Or what happens?

How index.php is found? Why apache decided to run it?

My configuration: Windows Vista, Apache Apache/2.2.14 (Win32) PHP/5.3.1 (with php module).

(Indeed the problem is the rule is actually rewritten before mod_rewrite - this is when mod_rewrite is enabled. This causes that RewriteCond %{REQUEST_FILENAME} !-f is always false, because /foo/bar is trimmed before RewriteCond).

Upvotes: 1

Views: 196

Answers (2)

Matthew Smith
Matthew Smith

Reputation: 6255

Maybe you should use $_SERVER[REQUEST_URI] instead, afaik, SCRIPT_FILENAME tells you which file php was started with.

Upvotes: 0

Pekka
Pekka

Reputation: 449485

This is caused by the AcceptPathInfo Apache directive.

It treats everything up to

http://localsite/index.php

as the resource, and puts

/foo/bar

into the $_SERVER["PATH_INFO"] variable.

It's sometimes used as a poor man's URL rewriter when mod_rewrite isn't available - with the downside that in a normal configuration, there has to be a .php somewhere in the URL.

Your options are to turn this off, or to use a different URL - depending on your situation.

Upvotes: 3

Related Questions