Apache under 301 redirect Code (because I'm using Windows 2003 + Apache so this article is only available to APACHE servers.) )
Create a new. htaccess file and enter the following (you need to turn on mod_rewrite):
1) Turn the domain name without www to the domain name with www
Options +followsymlinks
Rewriteengine on
Rewritecond%{http_host} ^163.com [NC]
Rewriterule ^ (. *) $ http://www.163.com/$1 [l,r=301]
2) redirect to new domain
Options +followsymlinks
Rewriteengine on
Rewriterule ^ (. *) $ http://www.001.com/$1 [l,r=301]
3) Use regular 301 redirect for pseudo-static
Options +followsymlinks
Rewriteengine on
Rewriterule ^news-(. +) \.html$ news.php?id=$1
Turn the news.php?id=123 address to news-123.html.
Apache under vhosts.conf configuration 301 redirect
In order to implement URL normalization, SEO usually turn the domain name without www to the WWW domain name, vhosts.conf is configured as:
<virtualhost *:80>
ServerName www.001.com
Documentroot/home/fari001com
</VirtualHost>
<virtualhost *:80>
ServerName fari001.com
Redirectmatch permanent ^/(. *) http://www.001.com/$1
</VirtualHost>
Apache Redirect (301) to new domain name