Apache will redirect without www domain 301 to the domain name with www _linux

Source: Internet
Author: User


Believe that a lot of webmaster friends have such problems appear. That is, the domain name with the WWW prefix and the top-level domain name without the WWW prefix are different. This problem is mainly due to the search engine for the top-level domain name and two-level domain name weight difference caused.
There is no doubt that the only domain name can bring you more benefits. Whether it is with the WWW or not with www. Because, so whether the user or search engine will remember your site's unique domain name. Nor will it cause a diversion of weights.
The following days tell you how to force a user or search engine to redirect to a unique domain name in. htaccess.

Copy Code code as follows:

#强制重定向到www
Rewriteengine on
Rewritecond%{http_host} ^jb51.net/[NC]
Rewriterule ^ (. *) $ http://www.jb51.net/$1 [l,r=301]

#强制重定向到不带www的顶级域名
Rewriteengine on
Rewritecond%{http_host}!^jb51.net/$ [NC]
Rewriterule ^ (. *) $ http://jb51.net/$1 [l,r=301]


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.