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!
htaccess没有生效