问题原文
原帖链接 · Patrick Kenny · CC BY-SA 3.0
I have a Drupal 7 site served exclusively using SSL with the "bare" domain (no www).
But, I see that in Google Webmaster Tools, I can add the following:
http://example.comhttp://www.example.comhttps://example.comhttps://www.example.com
I have added all of these for my site, accessed Site settings, and set it to Display URLs as example.com.
This is true for the example.com + www.example.com pair and the https://example.com + https://www.example.com pair. Do I need to do anything more to mark my https sites as duplicates of the non-https sites?
已采纳解答
原帖链接 · Simon Hayter · CC BY-SA 4.0
Add all variations of your site to WMT
While the site address move tool may not treat protocols, url changes and sub domains as new sites, the rest of Webmaster Tools does treat protocols and sub domains as separate sites. You should add all variations of your site, below is an example of my site BYBE added to WMT with all variations, you should do the same. (recommended by John Mueller from Google, See comments below this answer).
(source: bybe.net)
301 redirects recommended by Google
If you plan to serve the website as partial ssl or complete then you should setup good redirects, as recommended by Google:
Prepare for 301 redirects Once you have a mapping and your new site is ready, the next step is to set up HTTP 301 redirects on your server from the old URLs to the new URLs as you indicated in your mapping. Keep in mind the following:
- Use HTTP 301 redirects. Although Googlebot supports several kinds of redirects, we recommend you use HTTP 301 redirects if possible.
- Avoid chaining redirects. While Googlebot and browsers can follow a "chain" of multiple redirects (e.g., Page 1 > Page 2 > Page 3), we advise redirecting to the final destination. If this is not possible, keep the number of redirects in the chain low, ideally no more than 3 and fewer than 5. Chaining redirects adds latency for users, and not all browsers support long redirect chains.
- Test the redirects. You can use Fetch as Google for testing individual URLs or command line tools or scripts to test large numbers or URLs.
Setting up the redirect in Apache
Setting up redirects in Apache, ngInx, IIS is pretty straight forward, below is examples of redirecting 301 from HTTP to HTTPS in Apache2
.htaccessfile.Enforce SSL on specific pages and disable on rest
This script will remove SSL on all other pages part from the login page and register page, you can add more just use
|as the separator between file names.mod_rewrite:
RewriteCond %{HTTPS} on RewriteCond %{SCRIPT_FILENAME} !\/(login|register)\.php [NC] RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]Enforce SSL on the entire site
If you want to enforce SSL on the complete site then you can use mod_rewrite to detect HTTPS off.
mod_rewrite:
RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}Sitemap changes
Since you are changing protocol you need to add a new property to Google as HTTPs, this will have no sitemap submitted as default, you will need to ensure that your sitemap contains all the new URLS and then submit it under the HTTPS property variation.
You should also inform Google your preferred domain (variation):
Specify a preferred domain:
- On the Search Console Home page, click the site you want.
- Click the gear icon , and then click Site Settings.
- In the Preferred domain section, select the option you want.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
