互联网技术 · 2024年2月20日

URL 301重定向的标准是什么

我们会遇到一些情况,其他网站链接到你网站是时,会用下面的链接:

www.example.com

example.com

www.example.com/index.html

example.com/index.php

而这样导致:你站点主域名的pr值分散到其他几个URLs了。

如果你用301重定向把其他三个URL转到

www.example.com

PR也就集中在主域名:www.example.com 了。

301重定向具体办法:

设置.htaccess文件(只适用于linux系统,并需要虚拟主机支持。)

使访问example.com的时候就会自动转到www.example.com;

在.htaccess文件里写上以下代码即可。

RewriteEngine on

RewriteCond %{http_host} ^mydomain.com/ [NC]

RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301]

了解本站的.htaceess文件设置,请 点击这里

注意:URL标准化的301重定向(以上代码)需要写在其他URL-rewrite代码之前。

文章来源:懒猫seo博客

来源地址:http://www.lanmaoseo.com/seojs/7074.html

OpenMagic API

Need more than content? Move into the product flow.

If you are here for model access, pricing, developer docs, or the future API console, the dedicated product path now lives on api.openmagic.ai.

登录免费注册