Skip to content

Instantly share code, notes, and snippets.

@lynt-smitka
Last active March 13, 2024 18:56
Show Gist options
  • Star 24 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save lynt-smitka/b5ff2cab70443c17a214006a4d5bc48c to your computer and use it in GitHub Desktop.
Save lynt-smitka/b5ff2cab70443c17a214006a4d5bc48c to your computer and use it in GitHub Desktop.
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;
}
...
}
}
@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

@francospatz
Copy link

Hello from the future. This is not working for me right now

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