For the purpose of SEO, PR value transfer, URL conversion, we need to use 301 redirect when the website is first built and website migration, usually including domain name to domain name, directory A redirect to a directory and a separate URL to another separate URL.
For 301 redirection on a virtual host, there are two most common methods: the first one is to use cPanel settings. Using cPanel is fairly straightforward. Log in to your cPanel–>Domain–>Redirects and select the appropriate options to complete the setup, which is not discussed here. The second is to edit .htaccess directly. The essence of both is to modify the file .htaccess, only the former is manually edited, the latter is done by cPanel. The second method introduced here is mainly.
Note: Be sure to back up the .htaccess file in the appropriate directory before setting the 301 redirect.
1. Redirect domain.com to www.domain.com
This kind of redirection is designed to make the domain name unique, which is what the website SEO must do, and then redirect www.domain. Com to domain.com is also for the same reason, but in a different form. Open the .htaccess file and add the following rules. (The following rules are for the primary domain name, the subdomain should be modified, otherwise the subdomain will be rewritten. The following will explain this specifically.)
RewriteEngine On
RewriteCond %{HTTP_HOST} !^ Www.domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com$1 [L,R=301]
2. Redirect www.domain. Com to domain.com
RewriteEngine On
RewriteCond %{HTTP_HOST} !^domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com$1 [L , R=301]
3. Redirect olddomain.com to www.newdomain.com
RewriteEngine On
RewriteCond %{HTTP_HOST} !olddomain.com$ [NC]
RewriteRule ^(.*)$ http://www.newdomain.com$1 [L,R=301]
4. Redirect olddomain.com to newdomain.com
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !olddomain.com$ [NC]
RewriteRule ^(.*)$ http://newdomain.com$1 [L,R=301]
5. Redirect domain.com/file/file.php to otherdomain.com/otherfile/other.php
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^file/File.php$ http://www.otherdomain.com/otherfile /other.php [R=301,L]
5. Redirecting domain.com to www.domain.com without affecting subdomains
Special instructions do not affect subdomains Because the method mentioned above is only feasible without the subdomain name. If the domain name contains a subdomain, and the subdomain does not want to be redirected, then the following method is needed to perform the 301 redirect;
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www.45it.com|
T.webjx.com)$[NC]
RewriteRule ^(.*)$ http://www.45it.com$1 [L,R=301]
The above code description: first The line indicates that mod-rewrite is enabled, and the second line indicates the object to be redirected. The code means all the domain names except the two domains www.45it.com and t.webjx.com, because this blog contains The meager t.webjx.com of a subdomain means that when the domain name is t.webjx.com, no redirection is performed, and the third line indicates the target to be redirected. The above is an example, in fact, the main idea is still a regular expression, if there are multiple subdomains do not want to redirect, the same can be added in the second line! Any questions can be raised later, I know as much as possible to answer.
Special note is that the methods in this article are only applicable to systems that support htaccess files, that is, only for Linux systems. As for the space of the windows system, I have not studied it yet.
T100 G11 After removing 1 memory, the power-on self-test will report an error, prompting memory size
This article takes Serv-U6.4 as an example. Setting method: Double-click to open S
As mentioned above, we need to track and log the operation of each us
“/” Server error in the application. The program is not registered on the local computer
Nginx 301 302 redirect jump configuration tutorial
Windows Server's three major crashes and avoidance methods
Analyze TCP packet headers using tcpdump
Preventing malicious attacks Protecting DNS servers 3 methods
Exchange administrator needs to know the DST data summary
3 major server hardware failures Have you ever encountered
Windows Server 2003 Practical Tips
Hardening security Configuring SSL
Solve IIS can not display Chinese name image problem
Serv-U version 6.1 ftp server software garbled problem
Unable to load an instance of ISAPI filter
Finding application pool pid through iisapp command to solve IIS CPU usage is too high.
Hardware and software together to solve the problem, the computer has no sound problems.
Setting the PIN code for Windows 8 to log in
Win8.1 system disk occupancy rate is high or even 100% solution
Windows8 new logo is "spit": or into a "brand disaster"
Computer memory stick problem?
Win10 system Outlook mail and calendar application shortcuts summary
Easily solve the Windows 7 system sounds suddenly big and small