Skip to content

Instantly share code, notes, and snippets.

@faustman
Last active December 12, 2015 12:09
Show Gist options
  • Save faustman/4770362 to your computer and use it in GitHub Desktop.
Save faustman/4770362 to your computer and use it in GitHub Desktop.
Pass subdomain to rewrite rule. Nginx
# Redirect http://test.domain.com to http://domain.com/?utm_source=test&utm_medium=423525
server {
listen 80;
server_name *.domain.com;
if ($host ~* ^([a-z0-9-\.]+)\.domain\.com$) { set $subdomain $1; }
rewrite ^ http://domain.com/?utm_source=$subdomain&utm_medium=$date_gmt permanent;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment