htaccess没有生效_没有使用.htaccess的WWW

htaccess没有生效

There are some clear benefits to removing the "www" from your URLs:

从您的网址中删除“ www”有一些明显的好处:

  • Shorter URLs

    较短的网址
  • Prevention of Google search engine penalties for duplicate content

    防止Google搜索引擎对重复内容的处罚
  • Less bandwidth usage if you have many links per page

    如果每页有很多链接,则带宽使用量较少

Luckily, removing the WWW from your page URLs (and subsequent Google listings) can be done inside your .htaccess file so that you wont have to go into every page on your website and remove the "www" from your anchors.

幸运的是,可以从.htaccess文件中删除网页URL(以及随后的Google列表)中的WWW,这样您就不必进入网站的每个页面并从锚点中删除“ www”。

.htaccess代码 (The .htaccess Code)

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]

Conversely, if you'd prefer to use "www" in all of your URLs, you can code:

相反,如果您希望在所有URL中都使用“ www”,则可以编写以下代码:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]

Save some URL characters and remove WWW from your site!

保存一些URL字符并从您的站点中删除WWW!

翻译自: https://davidwalsh.name/no-www

htaccess没有生效

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值