Skip to content

Instantly share code, notes, and snippets.

@geckoseo
Last active April 13, 2020 19:31
Show Gist options
  • Save geckoseo/414fac9f1e9259a260594ba5c03d81c6 to your computer and use it in GitHub Desktop.
Save geckoseo/414fac9f1e9259a260594ba5c03d81c6 to your computer and use it in GitHub Desktop.
SpinupWP Nginx Configs - Strip fbclid query string from url when page is linked to from Facebook
######################
# Consists of 2 parts
######################
# Part 1 - first snippet (map) needs to go before the server block
# create a custom config file in /etc/nginx/sites-available/{DOMAIN}/before
# remove fbclid argument from the end of the url
map $request_uri $redirect_fbclid {
"~^(.*?)([?&]fbclid=[a-zA-Z0-9_-]+)$" $1;
}
# Part 2 - second snippet (return 301) needs to go in the server block
# create a custom config file in /etc/nginx/sites-available/{DOMAIN}/server
# check if redirect map is active, do 301 to the page url
if ( $redirect_fbclid ) {
return 301 $redirect_fbclid;
}
@geckoseo
Copy link
Author

geckoseo commented Apr 13, 2020

SpinupWP is a Cloud-Based Server Control Panel designed for WordPress.

The snippets above are examples made specifically for SpinupWP.

  • Read the code comments. The configuration consists of two new files.
  • The code comments are tips only, you don't need to add them to the actual files.
  • Change the file names and comments to whatever you want.

Check configs for errors before reloading Nginx

sudo nginx -t

Reload Nginx when ready

sudo service nginx reload

Official Documentation

Documentation for Nginx Settings in SpinupWP

Referral Link

Sign up to SpinupWP and get $50 in credit 30 days after signing up.

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