Apache top-level domain jump

Source: Internet
Author: User

Apache top-level domain jump

Toss the site also has a large six months, yesterday to listen to a colleague said our website through the domain name without www can also be accessed, with the WWW can also be accessed, the search engine is included in the situation is separately,

Originally has not cared about these details of things, such as our website is www.dt.com, without the WWW is dt.com, and not with the WWW is the real top-level domain name, with the WWW is a two-level domain name,

Now responsible for the search engine included the situation of colleagues asked us to let dt.com jump to www.dt.com, began to think of is to modify the http.conf file below Apache, not very understand the forwarding rules inside,

Found that the previously configured forwarding rules are a certain level two domain name jump to the specified IP, or pseudo static configuration, if the configuration top-level domain name jump to level two domain name.

Apache did not find a way, and think of a domain name management, domain name management inside the configuration of the domain name forwarding, it is estimated that the domain name provider in the toss, said temporarily does not provide forwarding function.

Search again today for the rewrite URL method of Apache, as follows:

Options +followsymlinks

Rewriteengine on

Rewritecond%{http_host} ^dt\.com

Rewriterule ^ (. *) $ http://www.dt.com/$1 [r=permanent,l]

Here to determine whether the current server variable http_host is equal to dt.com, for the true rewrite, in accordance with the r=permanent for permanent redirection, L said

And immediately stop the rewrite operation and no longer apply other overriding rules

If you do not write r=permanent, the default is 302 temporary redirection, r=permanent or r=301, which is permanent redirection.

References: Http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html#RewriteRule

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.