apache 301重定向

apache 301跳转对seo是友好的,所以用apache的配置文件进行301跳转时很有用的。

修改 apache配置文件

例如,我现在服务器上的网站域名是 www.mytwo.com ,我又想让www.myone.com也打开www.mytwo.com,代码如下

<VirtualHost *:80>
ServerName www.myone.com
RedirectMatch Permanent ^/(.*) http://www.mytwo.com/$1
</VirtualHost>

另一个示例,apache虚拟主机配置示例:

<VirtualHost 213.5.65.230:80>
    ServerAdmin cc@cc.com
    ServerName www.hellokey.com
    ServerAlias hellokey.com
    RedirectMatch Permanent ^/(.*) http://www.hellokeykey.com/$1
</VirtualHost>

将www.hellokey.com 301 跳转到 www.hellokeykey.com

如果使用.htaccess 来实现,直接到网址:http://www.htaccesseditor.com/sc.shtml 来设置就好了,这个是在线的傻瓜编辑器,将生成的.htaccess贴到我们的.htaccess文件就好了。

转载标明出处:hellokeykey.com 右兜钥匙