语言重定向与mod_rewrite的 [英] Language Redirect with mod_rewrite

查看:143
本文介绍了语言重定向与mod_rewrite的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个提供7种语言的站点。

I have a site that is offered in 7 languages.

我希望能够重定向基于所述浏览器语言只有当用户访问主页上的用户。这是为增加可用性,当涉及到有机交通。我需要这个重定向仅适用于网页的网站也发出具体到每一种语言邮寄,如果一个用户被重定向他们将无法正常工作。

I want to be able to redirect the user based on the browser language only when the user is visiting the homepage. This is meant for added usability when it comes to organic traffic. I need this redirect to only apply to the homepage as the site also sends out mailers specific to each language and they will not work if a user is redirected.

另外每种语言是一个子域。即与www.site.com英语de.site.com德国。 梅勒的URL将类似于:www.site.com/home/login?query=string

Also each language is a sub-domain. i.e. www.site.com for English and de.site.com for German. Mailer URL's would look similar to: www.site.com/home/login?query=string

我想用.htaccess文件,如果有可能做到这一点。

I'd like to do this with an .htaccess file if possible.

任何人都可以提供见解?

Can anyone offer insight?

感谢。

推荐答案

由于您只希望重定向,而在您的主页,你可以做这样的(assumging www.xyz.com是您的主页)

Since you only want to redirect while on your homepage , you can do like this (assumging www.xyz.com is your home page)

RewriteCond %{HTTP:HOST} www.xyz.com  // user visiting default
RewriteCond %{HTTP:Accept-Language} ^de [NC] // browser language German
RewriteRule ^$ de.xyz.com [L,R=301] // R=302 if you need temporary redirect

<一个href="http://tech-blog.borychowski.com/index.php/2009/03/htaccess/redirect-according-to-browser-language-mod-rewrite-and-http_accept_language/">http://tech-blog.borychowski.com/index.php/2009/03/htaccess/redirect-according-to-browser-language-mod-rewrite-and-http_accept_language/

这篇关于语言重定向与mod_rewrite的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆