Apache301 redirection configuration method in Linux system

黄舟
Release: 2017-05-31 11:39:08
Original
2151 people have browsed it

问题描述


ECS Linux 服务器上的 Apahce 如何配置 301 重定向。

问题分析


一般是通过修改 Apache 的站点配置文件来实现。

解决方案


例如,要把域名 test.com,重定向到 www.test.com,则需要修改 Apache 中站点的配置文件,添加 301 重定向的配置。

最主要就是以下配置:

ServerName test.com        #绑定的域名test.com
RedirectMatch  permanent  ^/(.*)  http://www.test.com/$1       #访问test.com,都跳转到www.test.com
Copy after login

Apache301 redirection configuration method in Linux system

添加好 Apache 的配置后,重启 Apache 生效,然后访问 test.com,就会 301 跳转到 www.test.com :

Apache301 redirection configuration method in Linux system

 

The above is the detailed content of Apache301 redirection configuration method in Linux system. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template