Skip to content

Instantly share code, notes, and snippets.

@Chaturaphut
Forked from lynt-smitka/fbclid-nginx.conf
Created April 30, 2019 01:23
Show Gist options
  • Save Chaturaphut/dd694f9150c0165c43ee5e34d0b8e3a0 to your computer and use it in GitHub Desktop.
Save Chaturaphut/dd694f9150c0165c43ee5e34d0b8e3a0 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;
}
...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment