重定向非www到www [英] Redirect Non-WWW to www

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

问题描述

我有我的服务器上约10域

i have about 10 domains on my server

site1.com
site2.com
site3.com

我想重定向非www WWW

site1.com www.site1.com

site2.com www.site2.com

我应该为每个站点添加htaccess的?

Should i add htaccess for each site?

我可以短这项工作在Apache的配置?

can i short this job in apache config?

推荐答案

在Apache配置下面的条目为每个域会做的伎俩。请注意,你应该做一个 301 (永久)重定向,以确保搜索引擎了解您的 WWW 地址是规范之一。

The following entry in your Apache configuration for each domain would do the trick. Note that you should be doing a 301 (permanent) redirect to make sure the search engines understand that your www address is the canonical one.

<VirtualHost *:80>
ServerName example.com
ServerAlias *.example.com

Redirect 301 / http://www.example.com
</VirtualHost>

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

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