Linux环境下apache服务器配置301跳转

时间:2020-02-05 14:10:59   收藏:0   阅读:102

Linux环境下apache服务器配置301跳转

基于ubuntu 16.04系统,使用 apache 进行布署,云服务器为阿里云

配置步骤

找到/etc/apache2/sites-available路径下的000-default.conf,写入以下代码

#不带www的域名转向到带www的域名
<VirtualHost *:80>
ServerName www.xsyl0.com
DocumentRoot /var/www/html
</VirtualHost>
<VirtualHost *:80>
ServerName xsyl0.com
RedirectMatch permanent ^/(.*) http://www.xsyl0.com/$1
</VirtualHost>
/etc/init.d/apache2 restart #重启

因为小编最近在为自己网站配置301跳转,弄了将近半个小时才完成,查找其他博主的文章并不能有效的解决,所以在自己的网站配置成功之后写了这篇博客。

原文:https://www.cnblogs.com/hiiu/p/12263315.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!