0

I need to allow indexing of user protected pages for Facebook sharing. Basically, I have a RoR app that offers coupons and I need for users to be able to share the coupon on facebook. Only problem is that a user must have an account to view all the coupon details on each coupon's page. I want them to be able to share the coupon (title, price only) with a link to that coupon, but the link to the coupon will essentially redirect to the sign up page if the user does not have an account. Therefore, when Facebook (and other indexing robots) go to pull info from the coupon URL, they also get redirected to the sign up page and index the sign up page info instead of the coupon page info.

Any way to allow indexing of each coupon page for crawlers, but redirect actual users to the sign up page?

Ralph Haynes
  • 83
  • 10

1 Answers1

0

Found this post... Ended up using the second answer given. In the coupons controller's show method, I just updated my before_filter to something like:

if ( !request.env["HTTP_USER_AGENT"].match(/\(.*https?:\/\/.*\)/) && !user_signed_in? )
     redirect_to new_user_registration_path
end

Therefore when a request is made to view a coupon, it will allow a robot through to index the page, but will redirect non-signed-in users to either register or login. Really only useful in my case for Facebook sharing, but I'm sure will help SEO and other indexing. I used Facebook developer tools to verify it was indexing properly.

Hope this is helpful to someone else out there.

Community
  • 1
  • 1
Ralph Haynes
  • 83
  • 10