I have never paid much attention to this blog jump problem. By accident, a friend said that my blog www.111cn.net and 111cn.net did not do 301. This is indeed the case. Although the main domain name 111cn.net is set in the blog background, when www.111cn.net is accessed, it does not jump. Therefore, the following code is added to. htaccess, which perfectly enables apache to redirect other domain names (such as domain names with www) to domain names without www and record them for sharing. The code is as follows:
Environment:
Windows
In Apache 2.2
The code to be implemented is as follows:
The code is as follows: |
Copy code |
RewriteEngine on RewriteCond % {HTTP_HOST} www.111cn.net [NC] RewriteRule ^ (. *) $ http://111cn.net/#1 [L, R = 301] |
If mod_rewrite is not available, you can also set mod_alias:
The code is as follows: |
Copy code |
RedirectMatch 301 ^ (. *) $ http://www.111cn.net |
Reminder
Load the Rewrite module:
Find httpd. conf in the conf Directory
LoadModule rewrite_module modules/mod_rewrite.so
Remove the comment symbol "#" from the front or add this sentence.