: Create htaccess infinite redirection to random URLs to prevent Facebook crawling I want make an infinite series of 302 redirects. For example: Visitor accesses example.com Which 302 redirects
I want make an infinite series of 302 redirects. For example:
Visitor accesses example.com
Which 302 redirects to example.com/abc
Which 302 redirects toexample.com/xzy
Which 302 redirects to example.com/ghi
... etc in an infinite loop with random URLs until timeout
I don't want Facebook bot to crawl my site. If I try to prevent it in the normal way, Facebook will still scrape text and images from my website. When my site is shared frequently on Facebook, I want my website to be blocked. If Facebook bot is stuck in redirect, it can not scrape my site.
More posts by @Cofer257
2 Comments
Sorted by latest first Latest Oldest Best
I tried to add this into .htaccess file:
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} (facebookexternalhit|FacebookExternalHit|Facebot) [NC]
RewriteRule ^(.*)$ ^ [R=302]
As already stated you don't "redirect", and certainly don't try to create an "infinite redirect", in order to block traffic. Purposefully creating an "infinite redirect" for any day-to-day webmastering is nonsensical.
Using robots.txt to block Facebook is probably the recommended way, but you mentioned in a comment on the duplicate question that you didn't want to use robots.txt for some reason.
So, based on your attempt, to block Facebook in .htaccess, the following should be sufficient:
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} (facebookexternalhit|facebot) [NC]
RewriteRule ^ - [F]
This will return a "403 Forbidden" for all requests where the user agent contains either facebookexternalhit or facebot (NC - not case-sensitive).
Reference:
The Facebook Crawler - User Agents
in an infinite loop with random URLs until timeout
Just for info, this is probably not done in .htaccess. Apache config (ie. .htaccess) does not do "random".
i want to make infinite redirection because i dont want facebook bot crawl my site. if do in the normal way, the facebook also trace my website, and when I share in highly frequency mysite on facebook then my website will be blocked. if make facebook bot stuck in redirect it can not trace mysite – Sheng Long
That tactic'll work perfectly, if you want to kill your server. Simply put, their hardware won't even sweat and yours will give in and fail.
This is security through obscurity, which is not security. Please don't implement his, or similar ideas, ever.
You're apperantly looking for a work-around for Facebooks spam checks, for which I will not provide a better solution, sorry.
Check out the API tools, post via those, to a max of that limit. I don;t know how many posts you make, but I don't think you're using Facebook as is entended.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.