laravel/laravel — Issue #116: Request::uri() fails to parse REQUEST_URI if accessed not by index.php
Author: dragonee
Created: 2011-10-12 00:38:07+00:00
State: open

When accessed via file other than index.php, `Request::uri()` fails to return correct path string and returns the path string prepended by the name of the PHP file.

This behaviour happens only in the case when `PATH_INFO` is not set, i.e. when accessing base url with no trailing slashes appended.

This patch in `system/request.php` should allow other index files to work:

- if (strpos($uri, $index = '/index.php') === 0)
+ if (strpos($uri, $index = '/' . Config::get('application.index') === 0)

The patch was tested against two cases:

* The `application.index` being set to any filename (such as admin.php)
* The `application.index` being set to an empty string with mod_rewrite enabled.

When `application.index` is set to an empty string, accessing http://host/path/index.php will result in `Request::uri()` returning `index.php`, but since we use mod_rewrite and set `application.index` explicitly to an empty string, it's not much of an issue.

Discussion thread: http://forums.laravel.com/viewtopic.php?pid=2447