- Options + FollowSymLinks
- RewriteEngine on
- RewriteCond % {HTTP_HOST} ^ domain.com [NC]
- RewriteRule ^ (. *) $ http://www.domain.com/#1 [L, R = 301]
If you are using a Windows host, set 301 redirection on the control panel. Recommended for editing: php pseudo-static url rewrite rewrite rules: an example of php url rewrite path rewriting Supplement: answering Shi touwang's question in the URL standardization comment may be helpful to you: As far as I know, HTML cannot perform 301 redirection. Only JS or meta refresh can be used in HTML, but not 301 redirection. Once the HTML is read, the 200 OK status code is returned. If your page is ASP or PHP, you can also perform 301 redirection: ASP:
- <% @ Language = VBScript %>
- <%
- Response. Status = "301 Moved Permanently" Response. AddHeader "Location", "http://www.domain.com"
- >
PHP:
- Header ("HTTP/1.1 301 Moved Permanently ");
- Header ("Location: http://www.domain.com ");
- ?>
In addition, the DOThtaccess file is just a common text file. you can use Notepad to create this file and place the command in the root directory of your account. You do not need to modify Apache. Q: How long can the search engine process a page with 301 redirection? After a webpage is reoriented with 301, will the pages of old domain names indexed by the original search engine be transferred to the new domain name directed. What will happen to the page of the old domain name indexed by the search engine? for example, how long will it take for the content in the old domain name to be transferred to the new domain name after site: www.xxx.com. A: If your old website uses HTTP 301 (permanent) redirection to direct to your new website, the new website will be automatically notified during search engine roaming and automatically updated within six to eight weeks. 301 redirection promotes search engine optimization From the perspective of search engine optimization, 301 redirection is the most feasible method for URL redirection. When the domain name of a website changes, the search engine only indexes the new website and transfers the original external links under the old address to the new one, in this way, the ranking of websites will not be affected by changes in the website. Similarly, when you use the 301 permanent redirection command to direct multiple domain names to the primary domain of the website, the ranking of the website will not have any negative impact. |