Reputation: 588
Is there some way to restrict access to one our pages to only allow Facebook's OpenGraph scraper system? We have multiple likes on one page (similar to Digg) and each 'like' needs its own OpenGraph tags which we have on separate pages via the page story.php?1
and ?2
etc. We do not want the user to be able to view story.php
as all they contain are the og: tags.
EDIT: It looks to be something I can do using the info in this post: http://facebook.stackoverflow.com/questions/7197919/how-can-i-move-a-url-via-301-redirect-and-retain-the-pages-facebook-likes-and-o
How can I exclude a particular domain from a HTTP 301 redirect. Can you help?
Upvotes: 0
Views: 1390
Reputation: 588
In the end I opted to add this to the story.php PHP code and it works perfectly:
<?php
if ($_SERVER["HTTP_USER_AGENT"] != "facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)") {
redirect('http://www.mywebsite.com', 302);
}
function redirect($url, $type=302) {
if ($type == 301) header("HTTP/1.1 301 Moved Permanently");
header("Location: $url");
die();
}
?>
Upvotes: 1