I am busy developing a Drupal 7 website. All nodes of content type "X" are displayed on my front page as well as on (possibly) multiple taxonomy term pages. But that is it, users are not allowed to access the single node page directly.
- I have restricted the user's access to
example.com/node/*
pages using the plugin "Rabbit Hole nodes", redirecting them toexample.com/#node-[node.nid]
using the "Token" module. - I have also implemented the "Facebook Like Button" module to provide a Like button for each node.
Each of these Like buttons are placed inside a generated iframe with following iframe Src.:
//www.facebook.com/plugins/like.php?href=http%3A%2F%example.com%2Fnode%2F1&layout=button_count&show_faces=true&width=450&font=arial&height=80&action=like&colorscheme=dark&locale=de_DE&send=false
Note: Look at the "href" value that is passed along. It uses the exact URL pattern (../node/*) that I am restricting access to.
I asked myself these questions:
- Does the Facebook crawler (user agent:
facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php
) actually have access to this? - Will "Rabbit hole nodes" not break this like functionality?
- Where will users from Facebook land when clicking on the Facebook "like" notification of their friend? I mean, it's restricted..
[Update] How it should actually work:
When accessing the URL example.com/node/1
the following should happen:
- Normal User (everyone except Facebook's crawler): Should be redirected to
example.com/#node-1
. - Facebook's crawler: Should not be redirected, instead it should just stay on the single node page
example.com/node/1
.
Possible solution:
One solution that I considered implementing is altering "Rabbit Hole nodes" module code and checking for the Facebook crawler user agent like this:
if (in_array($_SERVER['HTTP_USER_AGENT'], array( 'facebookexternalhit/1.1 (+https://www.facebook.com/externalhit_uatext.php)', 'facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)' ))) { // Don't execute Rabbit hole functionality } else { // Execute Rabbit hole functionality }
What are your opinions, ideas and solution approaches?