One customer and two domain names must be accessible, so they must be resolved to the virtual host. This is not good for SEO. How can this problem be solved? Perform 301 redirection!
In the past, 301 redirection rules were applied to other customers, that is, the access to domain names without wwww automatically jumps to domain names with www, for example, access to abc.com automatically jumps to www.abc.com!
301
If you have a server, it is convenient to set permanent redirection directly in IIS. If not, what about virtual hosts? The VM needs to support isapi rewrite. My server has already installed the isapi rewrite function, so you can add rules directly in Httpd. ini.
There are other methods for Linux server. isapi rewrite seems to only support Windows server, so Httpd is used. ini rules, so if it is normal to do a 301 jump to a domain name, then use the following rule code.
A single domain name performs 301 redirection and redirects to. COM with WWW. Domain name.
The code is as follows: |
Copy code |
RewriteEngine On RewriteCond % {HTTPS} (on )? RewriteCond % {HTTP: Host} ^ (?! Www.) (. +) $ [NC] RewriteCond % {REQUEST_URI} (. +) RewriteRule .? Http (? % 1 s): // www. % 2% 3 [R = 301, L] |
But the user has two domain names. What should I do? If the VM supports Httpd. ini. Modify the following rules.
The two domain names perform 301 redirection and jump to the domain name with WWW. Domain name. COM.
The code is as follows: |
Copy code |
RewriteEngine on RewriteCond % {HTTP_HOST} ^ www.111cn.net $ [NC] RewriteRule (. *) http://mingzi.111cn.net/#1 [R = 301, L, NC] RewriteCond % {HTTP_HOST} ^ 111cn.net $ [NC] RewriteRule (. *) http://mingzi.111cn.net/#1 [R = 301, L, NC] |