Zac
Zac

Reputation: 121

How can i redirect a url without controller in Symfony2?

I would like to redirect http://valessentia.com/de to http://valessentia.com. I tried the that:

valessentia_de:
    pattern: /de
    defaults:
        _controller: FrameworkBundle:Redirect:urlRedirect
        path: /
        permanent: true

But it's not working.

Upvotes: 0

Views: 272

Answers (2)

felipep
felipep

Reputation: 2512

Edit your .htaccess file inside the /web directory add following line after

RewriteEngine On

add

RewriteRule ^de/(.*)$ /$1 [L,R=301]

Upvotes: 1

René Höhle
René Höhle

Reputation: 27295

If i go to valessentia.de i'am redirected to /de so its working. The problem ist now that all your other routes aren't working because you have no language in your route.

When you click on a link you get an 404. Here is a short exmaple for a routing that includes the language:

_welcome:
    pattern:  /{_locale}/hello
    defaults: { _controller: AcmeDemoBundle:Welcome:hello, _locale: en}

Upvotes: 0

Related Questions