Create a new. htaccess file and enter the following content (mod_rewrite must be enabled ):
1) switch the domain name without WWW to the domain name with WWWCopy codeThe Code is as follows: Options + FollowSymLinks
RewriteEngine on
RewriteCond % {HTTP_HOST} ^ jb51.net [NC]
RewriteRule ^ (. *) $ http://www.jb51.net/#1 [L, R = 301]
2) redirect to a new domain nameCopy codeThe Code is as follows: Options + FollowSymLinks
RewriteEngine on
RewriteRule ^ (. *) $ http://www.baidu.com/#1 [L, R = 301]
3) use regular expressions for 301 redirection to achieve pseudo-staticCopy codeThe Code is as follows: Options + FollowSymLinks
RewriteEngine on
RewriteRule ^ news-(. +) \. html $ news. php? Id = $1
Add news. php? Ids0123the address is directed to news-123.html.
Configure 301 redirection in vhosts. conf in Apache
To achieve URL standardization, SEO usually redirects a domain name without WWW to a domain name with WWW. The configuration in vhosts. conf is as follows:Copy codeThe Code is as follows: <VirtualHost *: 80>
ServerName www.baidu.com
DocumentRoot/home/fari001Com
</VirtualHost>
<VirtualHost *: 80>
ServerName faribaidu.com
RedirectMatch permanent ^/(. *) http://www.baidu.com/#1
</VirtualHost>
In addition to the preceding two methods in Apache, there are other configuration methods and optional parameters. We recommend that you read the Apache documentation.