So all use Linux host, I will define a 301 redirect to facilitate SEO. Yesterday, as usual htaccess uploaded to the server, did not expect to post the site can not be accessed, a delete will return to normal. Read a lot of code, also did not find any problems. Simply re-learn the URL rewrite method.
Normalize URLs
Describe:
On some Web servers, a resource can have more than one URL. Standard URLs should be used in actual applications and releases, others are abbreviated or used only internally. Whatever form of URL the user uses in the request, the final sight should be the canonical URL.
Solution:
Performs an external HTTP redirect on all irregular URLs to change its display in the browser's address bar and its subsequent requests. The rule set in the following example replaces the/~user with the canonical/u/user and corrects the suffix slash that/u/user omits.
Rewriterule ^/~ ([^/]+)/? (. *)/u/$1/$2 [R]
Rewriterule ^/([Uge])/([^/]+) $/$1/$2/[R]
Normalize host names
Describe:
The purpose of this rule is to force a specific host name to be used instead of another name. For example, if you want to force the use of www.example.com instead of example.com, you can modify it on the basis of the following scenarios:
Solution:
For sites that are running on ports other than 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]
Refer to the above rules, found that their original code missing a! Number, plus the return to normal.
Options +followsymlinks
Rewriteengine on
Rewritecond%{http_host}!^do-javascript.com [NC]
Rewritecond%{http_host}!^$
Rewriterule ^/(. *) http://www.do-javascript.com/$1 [R=301,NC]