Therefore, I will define a 301 redirection for any Linux host to facilitate Seo. I uploaded htaccess to the server as shown in the following example yesterday. I did not expect the website to be inaccessible after it was uploaded, And it will return to normal after it is deleted. I read it many timesCodeAnd no problems were found. Simply re-learn the URL rewriting method.
Normalized URL
Description:
On some Web servers, a resource has multiple URLs. Standard URLs should be used in actual applications and releases, while others should be abbreviated or used only internally. No matter what form of URL the user uses in the request, the final view should be a standard URL.
Solution:
Execute an external HTTP redirection for all non-standard URLs to change the display in the browser address bar and its subsequent requests. In the following example, replace the rule set with the standard/u/user /~ And corrected the suffix slash that/u/user missed.
Rewriterule ^ /~ ([^/] + )/? (. *)/U/$1/$2 [R]
Rewriterule ^/([uge])/([^/] +) $/$1/$2/[R]
Canonicalized Host Name
Description:
The purpose of this rule is to force a specific host name to replace other names. For example, if you want to force www.example.com to replace example.com, you can modify it based on the following solution:
Solution:
For Sites running on non-port 80
Rewritecond % {http_host }! ^ Fully \. Qualified \. domain \. name [Nc]
Rewritecond % {http_host }! ^ $
Rewritecond % {server_port }! ^ 80 $
Rewriterule ^/(. *) http://fully.qualified.domain.name: % {server_port}/$1 [L, R]
For Sites running on port 80
Rewritecond % {http_host }! ^ Fully \. Qualified \. domain \. name [Nc]
Rewritecond % {http_host }! ^ $
Rewriterule ^/(. *) http://fully.qualified.domain.name/#1 [L, R]
After referring to the above rules, I found that my original code was missing! .
Options + followsymlinks
Rewriteengine on
Rewritecond % {http_host }! ^ Do-javascript.com [Nc]
Rewritecond % {http_host }! ^ $
Rewriterule ^/(. *) http://www.do-javascript.com/#1 [R = 301, NC]