Skip to content

Instantly share code, notes, and snippets.

@lynt-smitka
Last active July 2, 2023 01:14
  • Star 24 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Remove fbclid argument from the URL in Nginx
http {
...
# redirect map in http block - remove fbclid argument from the end
map $request_uri $redirect_fbclid {
"~^(.*?)([?&]fbclid=[a-zA-Z0-9_-]+)$" $1;
}
...
server {
...
# if redirect map is active, do 301 to the new url
if ( $redirect_fbclid ) {
return 301 $redirect_fbclid;
}
...
}
}
@lukapaunovic
Copy link

Thanks a lot.

@marcusprice
Copy link

Thank you for this.

@SalimF
Copy link

SalimF commented Nov 10, 2019

works

@dieudv
Copy link

dieudv commented Nov 14, 2019

works

@jorgedison
Copy link

Thank you.

@onofapolivio
Copy link

Thanks works.

@skyhi-github
Copy link

@lynt-smitka Sorry
Where to paste this file?

@skyhi-github
Copy link

@marcusprice Sorry where to paste this file?

@onofapolivio
Copy link

You can add it into nginx.conf like this

image

@onofapolivio
Copy link

@marcusprice Sorry where to paste this file?

And after add it into file /sites-available/default in server configuration

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment