我最近为我的项目买了几个其他域名。
我的问题很简单..
我想在我的项目中协调不同语言的每个域名。
Language Lauguage folder Different domains
English www.mysite.com/en www.mysite.com
Spanish (Spain) www.mysite.com/es www.mysite.es
German (Germany) www.mysite.com/de www.mysite.de
在上面的例子中..
如果有人访问www.mysite.de,系统会将他们重定向到www.mysite.com/de/,并在url中隐藏/de/。
如果有人访问www.mysite.es,系统会将他们重定向到www.mysite.com/es/,并在url中隐藏/es/。
如果有人访问www.mysite.en,系统会将他们重定向到www.mysite.com/com/,并在url中隐藏/en/。
你知道怎么处理它吗?
发布于 2013-11-05 18:17:03
如果语言目录是站点中的物理目录,则不需要使用重写。只需在apache conf中为每种语言声明一个虚拟主机即可。
<VirtualHost *:80>
DocumentRoot /path/to/mysite/en
ServerName www.mysite.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /path/to/mysite/de
ServerName www.mysite.de
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /path/to/mysite/es
ServerName www.mysite.es
</VirtualHost>
编辑:
我想我现在明白情况了。
一些重定向规则如何?
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.mysite\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/en/ [NC]
RewriteCond %{REQUEST_URI} !^/de/ [NC]
RewriteCond %{REQUEST_URI} !^/es/ [NC]
RewriteRule ^([^/]+)?/?$ /en/$1 [L,QSA]
RewriteCond %{HTTP_HOST} ^www\.mysite\.de$ [NC]
RewriteCond %{REQUEST_URI} !^/de/ [NC]
RewriteRule ^([^/]+)?/?$ /de/$1 [L,QSA]
RewriteCond %{HTTP_HOST} ^www\.mysite\.es$ [NC]
RewriteCond %{REQUEST_URI} !^/es/ [NC]
RewriteRule ^([^/]+)?/?$ /es/$1 [L,QSA]
编辑2:
编辑了重写条件,以仍然允许旧格式www.mysite.com/de等。
https://stackoverflow.com/questions/19786086
复制相似问题