How to implement Apache 301 page jump in Windows _linux

Source: Internet
Author: User
To achieve 301 page jump before you need to make changes to the Apache configuration such as

Apache does not open the Mod_rewrite module by default,

1, will

Copy Code code as follows:
#LoadModule Rewrite_module modules/mod_rewrite.so

This line is preceded by the # number removed, http.conf Site directory configuration, the other is the space users commonly used

To

Copy Code code as follows:
LoadModule Rewrite_module modules/mod_rewrite.so,


2, change allowoverride None to: allowoverride all

I. writing. htaccess file, about 301 redirects:

1 common to the domain name without www to the domain name with www example: web site. com Redirect to www. Web site. com

Copy Code code as follows:

Options +followsymlinks
Rewriteengine on
Rewritecond%{http_host} ^ website. com [NC]
Rewriterule ^ (. *) $ http://www. Web site. com/$1 [l,r=301]


If you have server privileges, we can modify it in http.conf.

two, the Apache under the vhosts.conf configuration 301 turn.

Copy Code code as follows:

<virtualhost *:80>
DocumentRoot "E:/xxx"
ServerName http://www. Domain name. Net
</VirtualHost>
<virtualhost *:80>
ServerName domain. Net
Redirectmatch permanent ^/(. *) http://www. Domain name. net$1
</VirtualHost>

Cases

Change the domain name without www to a domain name with www

Copy Code code as follows:

Options +followsymlinks
Rewriteengine on
Rewritecond%{http_host} ^xxx.cn [NC]
Rewriterule ^ (. *) $ http://www.xxx,cn/$1 [l,r=301]

Common Client Request error return code:

400-bad Request Error Requests
401 Authorization required Need verification
403 Forbidden Prohibited
404 Not Found cannot find the page
405 Method Not allowed
408 Request Timed out
411 Content Length Required
412 Precondition Failed
413 Request Entity Too Long
414 Request URI Too Long
415 Unsupported Media Type

You can use the FF browse Firebug to detect whether the 301 status code is returned
Related Article

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.