Because the blog is using http://www.111cn.net/As the blog domain name, so you want to implement http://www.111cn.net/All redirection (jump) to http://www.111cn.net /. At the same time, according to google's recommendations, use server-side 301 Redirection. To ensure that users and seo/seo.html "target =" _ blank "> are directed to the correct webpage, the best way is. The status code 301 indicates that a webpage has been permanently migrated to the new location. The following describes how to implement 301 permanent redirection in apache. You must have the permission to access the server's. htaccess file.
1. Redirect and RedirectMatch commands of the Apache module mod_alias
The two commands mentioned above use similar methods. The difference is that the latter RedirectMatch sends an external redirection syntax to the current URL based on regular expression matching:
Redirect [status] URL-path URL
RedirectMatch [status] regex URL
The status parameter can use the following HTTP status code:
Permanent
A permanent redirect status code (301) is returned, indicating that the location change of the resource is permanent.
Temp
Returns a temporary redirect status code (302), which is the default value.
Seeother
A "see" status code (303) is returned, indicating that the resource has been replaced.
Gone
An "obsolete" status code (410) is returned, indicating that the resource has been permanently deleted. If this status code is specified, the URL parameter is ignored.
Example:
The code is as follows: |
Copy code |
APACHE Redirect 301/old/old.htm http://www.111cn.net/new.htm Redirect permanent/one http://www.111cn.net/two RedirectMatch 301 (. * pai.gif $/login/eWebEditor/UploadFile/201022895956328.jpg |
2. Use mod_rewrite to rewrite the URL
The code is as follows: |
Copy code |
APACHE Options + FollowSymLinks RewriteEngine on RewriteCond % {HTTP_HOST} ^ 111cn.net/RewriteRule ^ (. *) $ http://www.111cn.net/$1 [R = permanent, L] |
Check whether the current server variable HTTP_HOST is equal to php100.com. If it is true, rewrite it. Perform permanent redirection according to R = permanent. L indicates that the rewrite operation is stopped immediately and other rewrite rules are no longer applied.
The following is my final. htaccess file, which is also incorporated into the wordpress rewrite rules.
The code is as follows: |
Copy code |
APACHE # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On # Redirect Options + FollowSymLinks RewriteCond % {HTTP_HOST} ^ 111cn.net $ RewriteCond % {HTTP_HOST }! ^ $ RewriteRule ^ (. *) $ http://www.111cn.net/$1 [R = 301, L] # Rewrite (blog) RewriteCond % {REQUEST_FILENAME }! -F RewriteCond % {REQUEST_FILENAME }! -D RewriteRule ^ blog/. */blog/index. php [L] RewriteRule .- </IfModule> # END WordPress |
Directory 301
The code is as follows: |
Copy code |
RewriteCond % {REQUEST_URI} ^/down/mb/ RewriteRule ^/down/mb/(. *) http://mb.111cn.net/$1 [R = permanent, L] |