<p dir="auto">I've encountered an inconsistent behavior with Request::getBaseUrl method when the Request URI does not include the SCRIPT_NAME (due for example to an apache url rewrite), but it includes a segment of the SCRIPT_NAME path.</p>
<p dir="auto">In RequestTest.php, if I add this data to the getBaseUrlData data provider, testGetBaseUrl fails:</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="//Test Fails
array(
    '/webmaster',
    array(
        'SCRIPT_FILENAME' =&gt; '/foo/bar/web/index.php',
        'SCRIPT_NAME'     =&gt; '/web/index.php',
        'PHP_SELF'        =&gt; '/web/index.php',
    ),
    '',            //getBaseUrl    Fails, '/web' returned
    '/webmaster',  //getPathInfo   Fails, 'master' returned
)"><pre class="notranslate"><span class="pl-c">//Test Fails</span>
<span class="pl-en">array</span>(
    <span class="pl-s">'/webmaster'</span>,
    <span class="pl-en">array</span>(
        <span class="pl-s">'SCRIPT_FILENAME'</span> =&gt; <span class="pl-s">'/foo/bar/web/index.php'</span>,
        <span class="pl-s">'SCRIPT_NAME'</span>     =&gt; <span class="pl-s">'/web/index.php'</span>,
        <span class="pl-s">'PHP_SELF'</span>        =&gt; <span class="pl-s">'/web/index.php'</span>,
    ),
    <span class="pl-s">''</span>,            <span class="pl-c">//getBaseUrl    Fails, '/web' returned</span>
    <span class="pl-s">'/webmaster'</span>,  <span class="pl-c">//getPathInfo   Fails, 'master' returned</span>
)</pre></div>
<p dir="auto">because in this case getBaseUrl returns '/web' and not ''. This make getPathInfo fails too (it returns 'master' instead of '/webmaster'),</p>
<p dir="auto">If the URI does not start with 'web' all works as expected:</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="//Test passes
array(
    '/administrator',
    array(
        'SCRIPT_FILENAME' =&gt; '/foo/bar/web/index.php',
        'SCRIPT_NAME'     =&gt; '/web/index.php',
        'PHP_SELF'        =&gt; '/web/index.php',
    ),
    '',          //getBaseUrl
    '/administrator', //getPathInfo
)"><pre class="notranslate"><span class="pl-c">//Test passes</span>
<span class="pl-en">array</span>(
    <span class="pl-s">'/administrator'</span>,
    <span class="pl-en">array</span>(
        <span class="pl-s">'SCRIPT_FILENAME'</span> =&gt; <span class="pl-s">'/foo/bar/web/index.php'</span>,
        <span class="pl-s">'SCRIPT_NAME'</span>     =&gt; <span class="pl-s">'/web/index.php'</span>,
        <span class="pl-s">'PHP_SELF'</span>        =&gt; <span class="pl-s">'/web/index.php'</span>,
    ),
    <span class="pl-s">''</span>,          <span class="pl-c">//getBaseUrl</span>
    <span class="pl-s">'/administrator'</span>, <span class="pl-c">//getPathInfo</span>
)</pre></div>
<p dir="auto">Hi,<br>
I have a problem setting the variable _locale in the route prefix.<br>
I have a route like this:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="acme_site:
    resource: &quot;@acmeSiteBundle/Controller/&quot;
    type:     annotation
    prefix:   /{_locale}/
    defaults:  { _locale: %locale% }
    requirements:
        _locale:  en|it"><pre class="notranslate"><span class="pl-ent">acme_site</span>:
    <span class="pl-ent">resource</span>: <span class="pl-s"><span class="pl-pds">"</span>@acmeSiteBundle/Controller/<span class="pl-pds">"</span></span>
    <span class="pl-ent">type</span>:     <span class="pl-s">annotation</span>
    <span class="pl-ent">prefix</span>:   <span class="pl-s">/{_locale}/</span>
    <span class="pl-ent">defaults</span>:  <span class="pl-s">{ _locale: %locale% }</span>
    <span class="pl-ent">requirements</span>:
        <span class="pl-ent">_locale</span>:  <span class="pl-s">en|it</span></pre></div>
<p dir="auto">If I go to <a href="http://www.example.com/en" rel="nofollow">www.example.com/en</a>         works<br>
but if I go to <a href="http://www.example.com" rel="nofollow">www.example.com</a>        returns me the error of route / not found.</p>
<p dir="auto">There is a bug? Or I forget something in the configuration?</p>
<p dir="auto">If I set my locale route by route this problem does not happen.<br>
I Symfony 2.3.1</p>