Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following line in nginx:

try_files $uri $uri/ /index.html;

As far as I understand, it rewrites all queries to files that are not found to index.html. Meaning, that index.html?foo=bar and idontexist.html?foo=bar leave the same result which screws up Google crawling.

How can I not rewrite but redirect to the default url?

The perfect solution would be even without the index.html. So would redirect using 301 to

share|improve this question
location / {
    try_files $uri $uri/ @to_home;

location @to_home {
    return 301 /$is_args$args;
share|improve this answer
up vote 0 down vote accepted

I've shortened VBart's code snippet above. It works as it should:

try_files $uri $uri/ / =301;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.