ZF2-211: Request :: detectBaseUrl



I'm not sure about this issue, but to work on windows / wamp, I need to modified the index var.

Indeed in the code the index is 0 and the $baseUrl generated is like that : "/zend/public/index.php" and never match with if case.

I have initialized the index to 1 and the zendSkeletonApplication start working.


I ran in the same kind of issue on Windows.

The site runs with baseurl like "/public/". What I noticed during the detectBaseUrl the 'SCRIPT_FILENAME' value includes a path not only the file so /public/index.php.

For testing I changed: $filename = $this->server()->get('SCRIPT_FILENAME', ''); to $filename = basename($this->server()->get('SCRIPT_FILENAME', ''));

Then it works, but only without adding the index.php. So just /public/ instead of /public/index.php

Hi arnaud and John,

Could you provide a unit test for that behaviour?

Cheers, Ben

Hi Ben,

I'm not that familiar with unit testing.

But I just downloaded the ZendSkeletonApplication and mapped public in IIS as public. Because of the issue it kept giving the error "The requested URL could not be matched by routing" and the stylesheets were not loaded.

It's not that hard after all, see this file:…

There you can find the method baseUrlandPathProvider(). Just add an array to it with three elements, where the first element is an array with supplied headers (see other examples), the second element being the detected base URL and the third one the base path.

Hi Ben,

Thanx for the info.

For the array would be like this, I think: array( array( 'SCRIPT_NAME' => '/cgx_site/index.php', 'REQUEST_URI' => '/cgx_site/', 'PHP_SELF' => '/cgx_site/index.php', 'SCRIPT_FILENAME' => 'C:\Inetpub\wwwroot\public\index.php', 'ORIG_SCRIPT_NAME'=> null ), '/cgx_site', '/cgx_site/index.php' ),

I created the following PR for fix this issue. Could you test the fix?