我使用amazon web services托pipe我的网站,因为我打算使用ELB服务,我需要将所有的stream量从http://example.comredirect到http://www.example.com 。
这可能通过DNS?
我使用Route 53作为我的DNS。 任何提示,将不胜感激。
你不能在DNS中做redirect。
相反,您需要一个发送HTTP 301redirect来响应mysite.com请求的HTTP服务器。
大多数注册商提供redirect服务器; 咨询你的。
甚至比不使用mod_rewrite有机食物更快(但运行没有mod_rewrite的Apache有什么乐趣?)是,你可以直接从你的网站configurationredirect。 这完全不需要创buildwebroot。 这应该在您的<VirtualHost *:80>部分为这个站点:
ServerName mydomain.com ServerAlias *.mydomain.* myotherdomain.* *.myotherdomain.* yetanotherdomain.* Redirect 301 / http://mymaindomain.com/
为了补充SLaks响应,处理这个问题的常见方法是在Apache中使用mod_rewrite并发送301redirect。 换句话说,让ELB将stream量发送到您的EC2实例上运行的Apache服务器。 然后让Apache发送一个redirect,如果主机名不包含www。
以下是一个示例代码片段:
RewriteEngine on RewriteCond %{HTTP_HOST} ^example.com RewriteRule ^/(.*) http:/www.example.com/$1 [R,L]
希望有所帮助。