How to achieve page Jump of apache 301 in windows

Source: Internet
Author: User

You need to modify the apache configuration before enabling page Jump 301, as shown in figure

By default, the mod_rewrite module is not enabled for apache,

1. Set

Copy codeThe Code is as follows: # LoadModule rewrite_module modules/mod_rewrite.so

Remove the # sign before this line, and configure the site directory for http. conf.

Change

Copy codeThe Code is as follows: LoadModule rewrite_module modules/mod_rewrite.so,

2. Change AllowOverride None to AllowOverride All.

1. Write the. htaccess file and write the 301 redirection statement:

1) A common example is to redirect a domain name without WWW to a domain name with WWW: website. com to www. Website. com.

Copy codeThe Code is as follows: Options + FollowSymLinks
RewriteEngine on
RewriteCond % {HTTP_HOST} ^ website. com [NC]
RewriteRule ^ (. *) $ http: // www. Website. com/$1 [L, R = 301]

If you have server permissions, We can modify them in http. conf.

2. Configure 301 redirection in vhosts. conf under Apache.

Copy codeThe Code is as follows: <VirtualHost *: 80>
DocumentRoot "E:/xxx"
ServerName http: // www. Domain Name. net
</VirtualHost>
<VirtualHost *: 80>
ServerName domain name. net
RedirectMatch permanent ^/(. *) http: // www. Domain Name. net $1
</VirtualHost>

Example

Redirect a domain name without WWW to a domain name with WWW

Copy codeThe Code is 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 request
401 Authorization Required needs verification
403 Forbidden
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 ff to browse firebug to check whether 301 status code is returned.

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.