home page Site building tutorial text

301 Redirect, skip to access with www without www

SEO taboo is that the weight of the main website is scattered. In order to prevent the weight of the main domain name from being scattered, general webmasters are used to redirecting the main domain name without www to the domain name with www. This can not only standardize the website, but also maximize the SEO effect, centralize the website weight, improve the website ranking, and at the same time bring users a more unified perception of the domain name. Next, we will introduce several effective ways to redirect the website domain name 301 to the website with www The htaccess file implements 301 redirection in W.htacc

301 permanent redirection is Search engine optimization A common domain name and address jump operation in can help us transfer the weight of domain names. We often encounter domain names with and without www 301 Redirect Before, whether users or Search Engines The same page of the website can be accessed through these two URLs. Users may not care too much because they can access the same page no matter which URL they use, but for search engines, it is two different URLs, which means that the weight of the same website page needs to be calculated separately, and the final result is Site weight Dispersion of.

 301 Redirect, skip to websites with www without www Ranking engine optimizes website weight 301 Redirect Figure 1

In order to prevent the weight of the main domain name from being scattered, general webmasters are accustomed to redirect the main domain name without www to the domain name with www, which can not only standardize the website, but also maximize the SEO effect, centralize the website weight, and improve Website ranking At the same time, it gives users a more unified look and feel of the domain name. Next, we will introduce several effective ways to redirect the website domain name 301 to the website with www.

. htaccess file implements 301 redirection

Add the following code in W.htaccess

 RewriteCond% {http_host} ^ umtheme. com [NC]//If it is accessed by the root domain name RewriteRule ^(.*)$  https://www.umtheme.com/ $1 [L, R=301]//Redirect to www and request that the address remain unchanged

Web.config implements 301 redirection

Add the following code to Web.config

 <rule name="301Redirect" stopProcessing="true">     <match url="(.*)" />     <conditions logicalGrouping="MatchAny">     <add input="{HTTP_HOST}" pattern="^umtheme\.com$" />     </conditions>     <action type="Redirect" url=" https://www.umtheme.com/ {R:0}" redirectType="Permanent" /> </rule>

Nginx implements 301 redirection

The configuration file of Nginx is usually vhost.conf. If you can't find it in the conf folder under the installation directory, you can use Baidu

 server {     listen       80;     server_name  umtheme.com;     return       301  http://www.umtheme.com $request_uri; }

Jump through js

This method does not need to modify the pseudo static rules, and jump through js

 <script language="javascript">      if (document.domain =="umtheme.com")     this.location = " http://www.umtheme.com " + this.location.pathname + this.location.search;      </script>

Note: JS code, please replace the two domain names with your own domain names

Reward
poster

Statement: Some of the resources on this site are original works on the site, and some are publicly shared and collated based on the Internet. The copyright belongs to the original author.
If it infringes your rights, please contact our website, and we will deal with it as soon as possible. Thank you. Please indicate the source of the transfer

Link to this article: https://www.umtheme.com/website/190.html

Related recommendations

Post comments

Thank you for your support