Support Forums

Redirecting facebook referral to the specific url

Hello.I am Cindy.I am really new to netlify.I copied the landing pages files from my computer to netlify. The landing page works fine on netlify. (https://nervous-hermann-70c0dd.netlify.app/post/1001/ )But now, I want visitors from facebook to go to the URL I specified, not the landing page on netlify.I created a .htaccess file but it didn’t work. I think netlify doesn’t support the .htaccess file.How can I redirect visitors who visit my landing page on netlify.app on facebook to another domain?

Does this help? Redirects and rewrites | Netlify Docs

I already checked, and dont understand anything.That’s why I added the “netlify newbie” tag to the topic.

Add a _redirects file with the content: /post/1001/ new_url 301!.

Note that, this will redirect all users who visit that URL, not just the ones from Facebook.

thanks for reply, i have added https://flamboyant-kepler-e52b99.netlify.app/post/1001/ to here but it doesn’t work

I don’t think it matches the syntax I showed above. Sorry for not being specific, but you don’t have to replace 301, you have to replace new_url.

my fault! like this? if yes, still didnt work



Have you uploaded this to Netlify? I mean, yes you indeed have, but you need to create a new website every time you upload. You can just update the old one.

Also, if you send the website’s files I can check what’s happening.

sending you, files

By the way, where can I edit my old website’s files?https://easyupload.io/ogn8n2

Go to https://app.netlify.com/sites/<site-name>/deploys/ and you can drag-n-drop the updated files just like you do when creating a new website. Replace <site-name> with the name of the site, for example frosty-villani-786f4d (from the above link).

Also, the folder that you sent does not contain the _redirects file.

EDIT: I see, you added the file in your post folder. You had to add it in the root folder.

Here’s the corrected folder: Dropbox - temp2.zip - Simplify your life

I added your corrected folder, yes it redirects to the google.But i want to prepare multiple landing pages to the one netlify.app domain (with folders like 1001, 1002, 1003,1004).And each landing pages should redirect to different urls. It it possible ? Let me show you sample.

This is the landing page (i think he prepared landing pages in folders like me)

But when we share this url (landing page) on facebook, it redirects to the another domain.Check the link if you want to click on facebook.


That person has used Netlify Functions. If they have not used Netlify to deploy a website and are using it only for Functions, I think it might go against the Terms of Service. @perry will be able to tell if that’s true.

Additionally, I don’t see what purpose this is serving. Why use redirects or functions instead of directly linking to the original link? Any particular reason?

Finally, if you can’t get this working with Functions, you’d have to add each URL manually to the same file.

Changing the domain extension can be good for facebook reach.

Can we hire you with cost for a redirect like this, through netlify functions? (if this not go against the terms of service.)

I’m suggesting 2 methods. The second one is better as it’s automatic, you need to do it for each post. The first one is same as adding more redirect rules to the file we discussed above. I’d rather stay with redirects itself as it’s free, and infinite redirects. Functions, on the other hand, are billable.

Create a folder name functions and create a file named post-1001.js. Add the following code to that:

exports.handler = async () => {
  return {
    statusCode: 301,
    headers: {
      location: 'https://www.google.com/'

Then you can share the URL on Facebook as https://<site-name>.netlify.app/.netlify/functions/post-1001/. You’d still have to set this up individually for each post.

If you want to manage it automatically, create the folder as mentioned above and create a file named redirect.js. Add the following code to that:

exports.handler = async event => {
  return {
    statusCode: 301,
    headers: {
      location: decodeURIComponent(event.queryStringParameters.url.replace(/\+/g, '%20'))

Then, you can link on Facebook like: https://<site-name>.netlify.app/.netlify/functions/redirect?url=https%3A%2F%2Fwww.google.com%2F

Basically, the target URL that you need, would go in the end (after url=) and it would have to be escaped. You can use tools like URL Decoder/Encoder to encode/decode URLs.

Thank you for your all effort to this time.

I did everything you told.I tried method 1. But the url you show is broken


Here is the screenshoot.

I forgot to mention, Function are not supported when deploying via drag-n-drop. You’d need to connect it to GitHub (or other Git providers), or deploy using command line as documented here: Get started with Netlify CLI | Netlify Docs.

Read more about Functions here: Functions overview | Netlify Docs

Thanks for advice

i uploaded the files on github and connected to netlify, deploy but…


check the github file…

Make sure your build settings are like this:


  • Repository should be your repo link (this should already be correct)
  • Base directory should be: temp2
  • Build command should be left blank
  • Publish directory should be left blank

Instead of this, I would recommend moving all files out of temp2 folder in your repo. Then, you won’t have to change this configuration.

Thank you,i think i did, you are best.


All we have to do is redirect to google.com to those coming from facebook, not everyone.Any information about that.