Facebook Redirect Links with Previu


I’m newbie into this so I really want your help.

I have a website that is hosted on a webhost and static website on netlify.

When I share a link on facebook (with netlify subdomain) and a guest clicks on it I want it to redirect from netlify subdomain on main domain without netlify.

How can I do this? I saw this on many websites.

Example website:

<iframe src="https://www.facebook.com/plugins/post.php?href=https%3A%2F%2Fwww.facebook.com%2Fcuteol%2Fposts%2F1356658511382653&show_text=true&width=500" width="500" height="486" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowfullscreen="true" allow="autoplay; clipboard-write; encrypted-media; picture-in-picture; web-share"></iframe>

My websites: https://cranky-goldwasser-dfce5c.netlify.app/
Main domain where I want the redirect: https://amanuntul.ro/

Many thanks

Hi @djndr,

Sounds like you are wanting to set up a Domain-level redirect as found in the Netlify docs.

In essence you create a _redirects file in your publish directory and add
https://cranky-goldwasser-dfce5c.netlify.app/* https://amanuntul.ro/:splat 301!

Hi! I have created the _redirects file but no succes… :frowning: where I need to create this file, in public_html of a wordpress website or on static website on netlify?

If you want your <your-site>.netlify.app domain redirected to your custom-domain.com you need to put the _redirects file inside the directory you publish to Netlify.

The file is created. Post is here published on Facebook Redirecting... but when I click on the post it’s the same domain not redirecting me to main domain.

I want to keep netlify subdomain for facebook posts but when someone clicks on the post go to main domain.

I’ve seen this weird trend. People are trying to do this because they say using the Netlify sub-domain gives them reach. This is the 3rd or 4th person asking this question. But, I suppose this thread is a duplicate of Redirecting facebook referral to the specific url

TL;DR: What you’re trying is not easily possible and I personally think, it’s not worth the efforts. But then I’m not a social media expert, so take that comment with a pinch of salt.

1 Like

Hi! I already tried everything from that post but it doesn’t work… I need help on this because I can’t understand what is that thread…

The methods I’ve suggested there are well tested and do work. But if they don’t work I have already mentioned another way there which is to use some kind of a server-side rendering here: Redirecting facebook referral to the specific url - #48 by hrishikesh

If even that doesn’t work for your case, I’m sorry there’s no other way I know of getting this working.

Also, when you say “it doesn’t work”, it’s not particularly helpful. If you actually mention what part doesn’t work or if you get some error or a special case where the code fails or something, then we can provide some debugging steps. But if you just say “it doesn’t work”, I’m sorry we can’t be of much assistance.

1 Like

So where I can put this code?

That goes in your functions folder: Configure and deploy Functions | Netlify Docs

1 Like

@djndr Have you verified that the _redirects file is at the top level of your site directory at Netlify? If it’s not in the correct place, none of your redirects will work.

1 Like


I finally did it but I have one little problem, works from all devices but from android is not redirecting me to main website…

The _redirects is stopped.

What is the solution?
Thank you!

Hi, @djndr. I see you deleted the site. To answer your question, we would need to test the site and we have no way to do so anymore.

If there are other questions or concerns, please let us know.