ZF2-211: Request :: detectBaseUrl

Issue Type: Bug Created: 2012-03-09T22:09:51.000+0000 Last Updated: 2012-05-20T18:44:39.000+0000 Status: Resolved Fix version(s): Reporter: arnaud (muby) Assignee: Maks 3w (maks3w) Tags: - Zend\Http

  • PhpEnvironment
  • baseurl
  • http

Related issues: - ZF2-206




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.


Posted by John Hermsen (johnh) on 2012-04-18T10:49:01.000+0000

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

Posted by Ben Scholzen (dasprid) on 2012-04-18T10:56:16.000+0000

Hi arnaud and John,

Could you provide a unit test for that behaviour?

Cheers, Ben

Posted by John Hermsen (johnh) on 2012-04-18T11:36:40.000+0000

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.

Posted by Ben Scholzen (dasprid) on 2012-04-18T11:41:56.000+0000

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.

Posted by John Hermsen (johnh) on 2012-04-18T11:55:38.000+0000

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' ),

Posted by Maks 3w (maks3w) on 2012-05-19T21:33:05.000+0000

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

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.