我目前有两个域名指向同一个应用程序。一个是法语网址(A),另一个是英文网址(B)。
现在我们希望使用第三个域名(C),它将是主要的域名。
所以,我需要在我的.htaccess重定向
A.fr/my/great/url到C.com/my/great/url?locale=fr
和
B.com/my/great/url到C.com/my/great/url?locale=en
如何在my .htaccess中执行此操作?
非常感谢
发布于 2012-11-09 01:05:20
在文档根目录中的htaccess中添加:
RewriteEngine On
# redirect from A.fr
RewriteCond %{HTTP_HOST} A\.fr$ [NC]
RewriteRule ^(.*)$ http://C.com/$1?locale=fr [L,R=301,QSA]
# redirect from B.com
RewriteCond %{HTTP_HOST} B\.com$ [NC]
RewriteRule ^(.*)$ http://C.com/$1?locale=en [L,R=301,QSA]规则需要在任何现有规则之前,特别是那些执行路由的规则。
发布于 2012-11-09 01:24:21
您可以使用简单的index.html文件宽度Meta Refresh标记
发布于 2012-11-09 22:00:47
好的,感谢@Jon Lin,正确的答案是:
RewriteEngine On
# redirect from A.fr
RewriteCond %{HTTP_HOST} A.fr$ [NC]
RewriteRule ^(.*)$ C.com/$1?locale=fr [L,R=301,QSA]
# redirect from B.com
RewriteCond %{HTTP_HOST} B.com$ [NC]
RewriteRule ^(.*)$ C.com/$1?locale=en [L,R=301,QSA]https://stackoverflow.com/questions/13292662
复制相似问题