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.