Symfony/Apache – htaccess rewrite my default route to other route without redirection

  .htaccess, apache, symfony

I have a multilingual website in Symfony with :

  • http://localhost/en for english website (Default)
  • http://localhost/fr for french website
  • http://localhost/es for spanish website

I want to rewrite my default route http://localhost to default website http://localhost/en.
All my english routes must pass into http://localhost without /en code in url.

For example:

  • http://localhost/crews must display the content of http://localhost/en/crews route
  • http://localhost/crews/1 must display the content of http://localhost/en/crews/1 route
  • […]

I’m using htaccess file generated by symfony/apache-pack package:

DirectoryIndex index.php

<IfModule mod_negotiation.c>
    Options -MultiViews

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    # For TEST
    RewriteRule ^crews$ /en/crews [L]

    RewriteCond %{REQUEST_URI}::$0 ^(/.+)/(.*)::$
    RewriteRule .* - [E=BASE:%1]

    # Sets the HTTP_AUTHORIZATION header removed by Apache
    RewriteCond %{HTTP:Authorization} .+
    RewriteRule ^ - [E=HTTP_AUTHORIZATION:%0]

    RewriteCond %{ENV:REDIRECT_STATUS} =""
    RewriteRule ^index.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ %{ENV:BASE}/index.php [L]

RewriteRule ^crews$ /en/crews [L] for my test, not working but when I’m adding [R] flag, the redirection is working good. But I don’t want to do a redirection because I don’t want to show en code in url.

How can I do this ?

PS: Sorry for my bad english

Source: Symfony Questions