Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

.htaccess redirect depending on language


Go to End


2 Posts   1760 Views

Avatar
wonnepfropfen

Community Member, 18 Posts

22 August 2012 at 8:47am

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.

Avatar
JonShutt

Community Member, 244 Posts

26 August 2012 at 10:20pm

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

}

}