How to prevent twitter crawler?


I’m using some php code on my website to count number of visits. When I’m sharing a link on twitter I get about 6 visits immediately.
I have tried to stop this by using ($_SERVER[“HTTP_USER_AGENT”], “Twitterbot/1.0”) , It works almost, But I still get some visits when I share the link, about 3 visits.
Plus when I’m checking database, I can see the visits from different IPs like

My question, How to prevent and stop twitter crawler and all IPs from twitter, when sharing a link on it?


Twitter’s IP ranges for the crawler are listed in the Cards Troubleshooting documentation. You are welcome to setup rules to deny access from those IPs. However, doing so will mean that Twitter cards (link previews) will never be rendered for any pages on your site. This is entirely your choice, of course!


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.