Create a new. htaccess file and enter the following (you need to turn on mod_rewrite):
1 Change the domain name without www to the domain name with www
Copy Code code as follows:
Options +followsymlinks
Rewriteengine on
Rewritecond%{http_host} ^jb51.net [NC]
Rewriterule ^ (. *) $ http://www.jb51.net/$1 [l,r=301]
2 Redirect to new domain
Copy Code code as follows:
Options +followsymlinks
Rewriteengine on
Rewriterule ^ (. *) $ http://www.baidu.com/$1 [l,r=301]
3) using regular 301 redirects to achieve pseudo static
Copy Code code as follows:
Options +followsymlinks
Rewriteengine on
Rewriterule ^news-(. +) \.html$ news.php?id=$1
Turn news.php?id=123 Such an address to news-123.html
Apache configuration 301 redirect in Lower vhosts.conf
In order to achieve URL normalization, SEO will usually change the domain name without www to the WWW domain name, vhosts.conf is configured as:
Copy Code code 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>
Apache In addition to the above 2 methods, there are other configuration methods and optional parameters, it is recommended to read the Apache document.