Yesterday was busy to relocate several of the company's overseas space sites to the Asian nodes of the virtual host, because there are several sites in the form of HTTPS Web site SSL certificate, because forgot to force HTTPS jump, I also forgot to set this, Because the relocation directly after the use of HTTPS access is not a problem, so it has passed, today by colleagues found that directly after the site has not forced to jump past.
Because the virtual host is using the Apache server architecture, we can directly add to the. htaccess pseudo static file in the root directory, and the specific operation is simple.
The code is as follows |
Copy Code |
Rewriteengine on
Rewritecond%{server_port} 80
Rewriterule ^ (. *) $ https://laobuluo.com/$1 [r,l]
|
If our site is in the root directory, add the file directly above to the. htaccess file in the current root directory, notice that the red text is replaced with our own URL.
The code is as follows |
Copy Code |
Rewriteengine on
Rewritecond%{server_port} 80
Rewritecond%{request_uri} subfolder
Rewriterule ^ (. *) $ https://laobuluo.com/subfolder [r,l]
|
This is in the corresponding subdirectory (subfolder), we replace our URLs according to the actual needs, and the corresponding subdirectories.
Summary, on such a simple setup, you can force HTTP to jump HTTPS URLs
Above from: http://www.itbulu.com/htaccess-https.html
First, with the WWW jump to without the WWW domain name
The code is as follows |
Copy Code |
Rewriteengine on Rewritecond%{http_host}!^111cn.net$ [NC] Rewriterule ^ (. *) $ http://111cn.net/$1 [l,r=301] |
Second, jump to www domain without www
The code is as follows |
Copy Code |
Rewriteengine on Rewritecond%{http_host} ^111cn.net [NC] Rewriterule ^ (. *) $ http://www.111cn.net/$1 [l,r=301] |
Generally is to use the above 2 methods, remember that it does not matter, with the old left the same record down, the next time to use the direct copy used.
New add if the site moved, old domain name all 301 jump to the new site:
code is as follows |
copy code |
Rewriteengine On Rewriterule ^ (. *) $ http://www.111cn.net/$1 [r=301,l] |