Serve a different robots.txt for HTTPS
According to Google, each protocol (here we’re talking about HTTP and HTTPS) should have it’s own robots.txt file. This makes sense, especially seeing as Google will see https://www.yoursite.com/ and http://www.yoursite.com/ as different web sites - which they’re probably not. Duplication is a bad thing.
I’ve recently noticed quite a few forum posts and blogs telling you how to redirect all HTTPS pages to HTTP using fancy regular expressions. Now don’t get me wrong, about 60% of my day is spent writing regex to do the other 40% of my work for me. But there’s a far simpler way. Why not just disallow Google to spider everything on HTTPS?
Sounds simple, but most of the time you wont have separate file structures for different protocols. If that’s your problem too, then use this handy snippet to seve a different robots.txt when the request is made over HTTPS.
# serve different robots.txt for https
RewriteCond %{SERVER_PORT} ^443$ [OR]
RewriteCond %{HTTPS} =on
RewriteRule ^robots\.txt$ robots_ssl.txt [L]
Now just create robots_ssl.txt and pop what Google suggest in to it:
User-agent: *
Disallow: /
No more duplication. Horah!
[Edit: thanks to Aahan for pointing out a typo in original post :)]
What others have been saying
What I've been tweeting
- @omid9 but that'd mean another team lost a place who expected one wouldn't it.Imagine if spurs lost a spot because Barca placed low but won! 8 hours ago
- RT @sunny_hundal: Twitter, I'm really disappointed this Cameron pic hasn't been turned into meme yet. Here's the transparent gif http:// ... 9 hours ago
- @omid9 why is it a disgrace? I'd prefer Spurs to be in the champs league, but you, I and all teams knew the rules before a ball was kicked. 9 hours ago
- @SteJay what a lovely place to live, eh? When it snows it's wonderful :) on Halyard Croft myself. 9 hours ago
- @thisgirlrox city will probably buy him just to take the piss 9 hours ago
Categories
- Databases (1)
- Geek (1)
- General (2)
- Mobile (3)
- Operating Systems (1)
- Out and About (1)
- Programming (7)
- Quick Tips (2)
- SEO (1)
- Servers (3)
- Software (1)
- Web Sites (1)
Tag Cloud
.htaccess 2.2 644 777 android apache apple backup blog blogging c++ checkout chmod chown dropbox file permissions flash froyo goldcard google hero htc ios ipad iphone iphone 4 nokia objective-c opencv php pleask rom root safe mode server su sudo svn symbian uploads villainrom vps wordpress www-data xcode


