谷歌为什么不放" http://"在我的网站名称?

时间:2016-09-29 16:54:01

标签: .htaccess mod-rewrite

我始终设置我的域名以避免www并使用http://,但谷歌从不索引http://,这意味着在Google搜索结果中我的网站始终显示为mywebsite.com

# activate URL rewriting
RewriteEngine on

# Remove www    
RewriteCond %{HTTP_HOST} ^www.mywebsite.com$ [NC]
RewriteRule ^(.*)$ http://mywebsite.com/$1 [R=301,L]

# do not rewrite links to the documentation, assets and public files
RewriteCond $1 !^(index\.php|public|images|robots\.txt)

# do not rewrite for php files in the document root, robots.txt or the maintenance page
RewriteCond $1 !^([^\..]+\.php|robots\.txt|sitemap\.xml)

# but rewrite everything else
RewriteRule ^(.*)$ index.php?/$1 [L]

问题是否与我的.htaccess文件有关?

1 个答案:

答案 0 :(得分:0)

您无法强制Google显示http://,如果网址以http://开头,Google会始终将其删除。如果网址以https://

开头,则会保留该网址

您可以使用您的htaccess文件控制www,但不能使用http://,并且http://mywebsite.com/ $ 1的目的不是告诉他显示http://,您必须指定协议,否则他将表现得像你指定了本地地址。

如果你检查谷歌搜索结果中的网址,你可以确认这一点,谷歌将显示协议部分,如果它不是http

相关问题