How to share on facebook if your website is blocked

If facebook has blocked your website, then still your can share your content without paying anything.

I had started my blog back in 2015. I managed it successfully till early 2018. Then I got busy with my job and never cared about my blog. As a result, I lost my AWS instance and my domain name. COVID-19 locked down me at home and I started my blog again, with this new domain name. I had previous articles but no traffic on the website. So I shared my best post in 20 facebook groups. After 10 minutes, I got over 20 notifications that my posts have violated facebook community guidelines. Consequently, my website was blocked. I tried to contact facebook several time but why should they care. Facebook has worst supporting system. No facebook means no traffic on a blog. And I found many people saying that their website was also blocked, and it is permanent. I like to be a good person, following the rules but arrogant super-rich make me to hack.

1. Progressive attempts for 20 minutes

I started with changing url by using https://bitly.com/. Facebook bot followed me there and didn't allow me to post. I was well aware that facebook uses og:url meta tag to identify the website. So I changed my og:url meta tag to some other website domain. For a moment it worked. I was able to post my website's short link. But after two minutes, I got notification that my post has been removed. This was really annoying.

Now I was sure about three things:

  1. Facebook bot will follow all redirects to my link and will remove my post immediately.
  2. If I did nothing, my blog will be garbage and will not receive any visitor.
  3. I had to create something
    1. that navigate people to my website
    2. but facebook bot can not detect my website url
    3. but facebook bot do receive same header that I have set in my post (for title, image and sub-title).
    4. My post in facebook group should look like original

2. Time to create proxy

I thought creating a script and deploying on a free server. This script will receive the traffic from facebook, including facebook bot and then return data from my real page, without static files (js and css), along with a JavaScript code that will redirect real people to my website.

Earlier I had created a laravel blog demo and hosted on heroku. Although I had updated that demo to perform as proxy but if you are  not aware of laravel framework then I will write a pure php code here.

Get free sub-domain and free web-hosting

Although heroku is free, but it is complicated and not best suited for just a few lines of code. I used heroku because I had a demo already running there. For this article I will use 000webhost. It is free and easy to deploy single page php website. First go to 000webhost. As this website checks for robots, you need to wait for 5 seconds. Then click on free signup and verify your email address. After this you can login to your dashboard. Click on create new app and select a sub-domain. You may need to select several times as many sub-domain names are already taken.

Create PHP Script

 Now, you will be redirected to your website's dashboard. There, you will find a big File Manager option. Click on Upload to open online file manager.

This will redirect you to your online file manager. There is a public_html directory where we will place our code. 

Double click or use first icon on top right to open public_html. We have to redirect all the requests on a single index.php file. So double click on .htaccess file and paste these 5 lines there.

  1. RewriteEngine on
  2. RewriteCond %{REQUEST_FILENAME} !-d
  3. RewriteCond %{REQUEST_FILENAME} !-f
  4. RewriteCond $1 !^(images|photos|css|js|robots\.txt)
  5. RewriteRule ^(.+)$ index.php/$1 [NC,L]

Save and close .htaccess file. Use top icons to create new file with name index.php.Edit this file and paste this code.

Note: You have to change www.flowkl.com with your domain name.

  1. <?php
  2. // put your website url here
  3. $site = "https://www.flowkl.com";
  4. // check if proxy is in the query params
  5. $has_proxy = isset($_GET['proxy']);
  6. if($has_proxy) {
  7. // adding proxy=true to tell website that this is a proxy request
  8. // you can remove js and css file on getting proxy flag it will make fast redirect.
  9. $homepage = file_get_contents($site.$_GET['proxy']."?proxy=true");
  10. echo $homepage;
  11. } else {
  12. // in normal case put some content here
  13. ?>
  14. <h1>Thank you for visiting!</h1>
  15. <p>This is basic tutorial on how to deploy php website in production</p>
  16. <p>For more tutorials check <a href="https://www.flowkl.com/category/php/">Flowkl.com</a></p>
  17. <?php
  18. }
  19. ?>

Save & close index.php file

Put some html content:

Free web hosting and sub-domain come with two conditions:

  • website has content
  • website received at least 100 unique visitors within a month

So we need to have some content there. Copy some from the internet and paste in else section.

3. Update you main website

Hide from facebook bot:

Now we have to hide your url from facebook. Add og:url tag in your website.

  1. <meta property="og:url" content="https://hkhk12.000webhostapp.com/proxy/{% now "dmYHis" %}?proxy={{request.path}}">

Note that i have used {% now "dmYHis" %} and {{ request.path }}. I am using Django for my website https://www.flowkl.com. First one is date-time filter that creates unique path every time facebook bot visit the website (through proxy) and second is right path of the post related to your website domain. Every programming language and framework has equivalent functions.

Note:  Facebook considers all urls same if request path (part before ?) is same. {% now "dmYHis" %} must not be static. It should be dynamic random number otherwise facebook will consider all posts same and it will show right title and images in facebook post. More important facebook can consider your proxy website spam to. Facebook. {{ request.path }} can be anything facebook does not care about this thing.

Redirect real user

Facebook bod does not execute javascript. So we need not to add complex script in our website. As we have proxy flag from proxy server, we can add this only when proxy flag is passed. Add this script in head of your base file.

  1. <script>
  2. // change flowkl.com with your own domain name
  3. if (!window.location.href.startsWith('https://www.flowkl.com') && !window.location.href.startsWith('https://flowkl.com')) {
  4. const path = window.location.href.split('?');
  5. if (path.length === 1 || path[1] === '' || path[1] === '/') {
  6. window.location.href = 'https://www.flowkl.com';
  7. } else {
  8. path[1].split('&').map(function(p, i) {
  9. const query = p.split('=');
  10. if (query['0'] === 'proxy') {
  11. // change this with your domain
  12. window.location.href = 'https://www.flowkl.com' + query[1];
  13. }
  14. })
  15. }
  16. }
  17. </script>

This code will check if content is loaded on your domain or not. If content is loaded on a different domain, then it will redirect users to your domain.

4. Final Step

I don't have to go through this if facebook has not blocked my website permanently with no relevant reason. Yes, I had posted in 20 groups but all groups were related to laravel, so my post was. More importantly, Facebook support is a nightmare. Finally, I can post on facebook.

Here is an example in on my facebook page Programming and Web development. For hiding bad url, I have used short link.

Conclusion

As everyone of you have thought that facebook can block this server also, that is true. But you can have infinite such server. If you don't want to repeat these steps again and again, then you should post smartly. Here is one more good news for you, I am going to write a Django app that can post automatically in facebook groups and twitter without even being noticed. This will reduce social marketing burden a lot.



ReactJS with Redux Online Training by Edureka

About Harish Kumar

Harish, a technical core team member at www.lyflink.com with five year experience in full stack web and mobile development, spends most of his time on coding, reading, analysing and curiously following businesses environments. He is a non-graduate alumni from IIT Roorkee, Computer Science and frequently writes on both technical and business topics.

Related Articles

PHP stands for PHP: Hypertext Preprocessor. PHP is known as a server side scripting and interpreter language for web ...
Introduction to PHP
In this tutorial, we will study about conditional statements (if else statements and switch statements). These statem...
Conditional statements in php
In this tutorial, we will study about strings and operations upon strings. Due to long length of this section, I have...
Strings in PHP (part-1)

Complete Python Bootcamp: Go from zero to hero in Python 3

Top Posts

Recent Posts

The Complete Web Developer Course - Build 25 Websites

Meet on Twitter

Subscribe

Subscribe now and get weekly updates directly in your inbox!

Any Course on Udemy in $6 (INR 455)

Development Category (English)300x250

Best Udemy Courses

PHP with Laravel for beginners - Become a Master in Laravel