简体   繁体   中英

Facebook like button is liking wrong url

First off, I saw similar posts already, but they weren't exactly what I am asking.

I used the Facebook Dev to create a like button for my website, stuck the code in and the the button showed up. The only issue is that it likes the wrong url when I click the button.

I'm pretty sure the issue is that I have it set to redirect automatically from mydomain.com to the most recent post. I think this is gumming up the works with the like button and causing it to like mydomain.com/mostrecentpost instead of simply liking mydomain.com.

Is there a way to correct this issue without having to get rid of the redirect (because that isn't an option)?

Sorry if that was a little wordy, wanted to make sure I explained the issue fully.

Is there a way to correct this issue without having to get rid of the redirect (because that isn't an option)?

Either don't redirect in those cases where the user agent header of the request points to it being Facebook's scraper ;

or set the canonical URL of http://example.com/mostrecentpost to just http://example.com/ using the appropriate Open Graph meta tag. (Although that would mean you would not be able to like a single post any more, because all of your posts would just point to your base domain as the “real” website; so the first is probably the better option.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM