views:

119

answers:

1

I'm trying to create a MVC framework when I noticed the $_SERVER['PATH_TRANSLATED'] variable is doing this:

[PATH_INFO] => /test/test2/test3
[PATH_TRANSLATED] => redirect:/index.php/test/test2/test3/test2/test3

This is when I'm accessing the PHP file by http://domain.tld/test/test2/test3
Notice how it is repeating after /test/

This is my .htaccess for rewriting:

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

Any ideas? I tried changing the RewriteRule rule around but nothing changed. The variable isn't that important for what I am trying to do however, I am wondering why this is happening and if I have something misconfigured.

Server Info:
Apache/2.2.3
PHP 5.3.1

Edit: This variable doesn't repeat itself under Lighttpd, as it reports:

[PATH_INFO] => /test/test2/test3
[PATH_TRANSLATED] => /home/kramer/public_html/test/test2/test3

So I am assuming it has something to do with Apache. I also tried FastCGI under Apache and it produced the same repeating result.

+1  A: 

If you are using mod_rewrite, then reading the PATH_TRANSLATED value will have no use in your script, since it will point to a non-existence file or path. You should use PATH_INFO in your index.php to know the URI that requested by user.

For an example, you can take a like at CodeIgniter's Router class. CodeIgniter can use several way to get the URI parameter, which is PATH_INFO, QUERY_STRING, REQUEST_URI, and ORIG_PATH_INFO.

If you are still curious with the strange behavior of your apache, maybe digging into the access log will reveal some clue to the culprit. However, if you not using this variables, just forget it. It server a different purpose, and your MVC will not going to use it.

Donny Kurnia
Yeah I wasn't plan on using the variable to begin with. Was just curious to why it is set like this. Thanks though.
KramerC