Skip to content

Instantly share code, notes, and snippets.

@mudge
Created September 20, 2010 12:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mudge/587828 to your computer and use it in GitHub Desktop.
Save mudge/587828 to your computer and use it in GitHub Desktop.
Nginx configuration to redirect requests for non-existent files to an external URI without using if.
# Redirect all requests for non-existent files to another web
# site, used on my own site to redirect people to my GitHub
# account page.
server {
server_name example.com;
location / {
try_files $uri $uri/index.html @external;
}
location @external {
rewrite ^ $scheme://anotherexample.com$request_uri redirect;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment