windows apache 301 page jump implementation method

  • 2020-05-06 12:09:59
  • OfStack

Changes to the apache configuration such as
are required before a 301 page jump can be implemented
The apache module mod_rewrite is not turned on by default,

1, will be

 #LoadModule rewrite_module modules/mod_rewrite.so

The # in front of this line is removed, http.conf site directory configuration, the other is
common space users
Instead of

LoadModule rewrite_module modules/mod_rewrite.so .  


2. Change AllowOverride None to AllowOverride All

I, write.htaccess file, for 301 redirection:

1) it is common to redirect a domain name without WWW to a domain name with WWW. Example: web.com redirects to www.web.com

 
Options +FollowSymLinks 
RewriteEngine on 
RewriteCond %{HTTP_HOST} ^ Web site .com [NC] 
RewriteRule ^(.*)$ http://www. Web site .com/$1 [L,R=301] 


If you have server permission, we can modify
in http.conf
ii, Apache, vhosts.conf is equipped with 301 steering.

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

Example

Redirect the domain name without WWW to
under the domain name with WWW
 
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 to verify
403 Forbidden prohibits
404 Not Found could not 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 see if a 301 status code is returned

Related articles: