Last active
April 13, 2020 19:31
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###################### | |
# 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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
SpinupWP is a Cloud-Based Server Control Panel designed for WordPress.
The snippets above are examples made specifically for SpinupWP.
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.