Jump to:

23023 Posts in 11882 Topics by 2830 members

General Questions

SilverStripe Forums » General Questions » .htaccess redirect depending on language

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 719 Views
  • wonnepfropfen
    Avatar
    Community Member
    18 Posts

    .htaccess redirect depending on language Link to this post

    Hi

    I'm trying to adapt the .htaccess so that german is sent to a specific URL and all other clients are sent to another URL.

    Right now I'm trying something like this:

    RewriteEngine On
    RewriteBase /

    RewriteCond %{HTTP:Accept-Language} ^de [NC]
    RewriteRule ^$ /home [L,R=301]
    RewriteRule ^$ /home-en [L,R=301]

    Unfortunatly it's not working. Would anyone know why?

    Thanks for a feedback.

  • Futureweb
    Avatar
    Community Member
    232 Posts

    Re: .htaccess redirect depending on language Link to this post

    I would just put PHP code in the INIT function of your home page

    public function init() {
       parent::init();

       if ($_SERVER["HTTP_ACCEPT_LANGUAGE"] == "en") {

          // redirect or set a session var, which tells the page to loads in different versions of text

       }

    }

    719 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.