Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

All my old content (which no longer exists) is in the path mysite.com/2007/*

How can I write a redirect in nginx to redirect any requests to 2007 back to the homepage?

At the moment they just display a 404.

Thanks

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

You didn't provide your config, but basically you need to insert this line into your "location" config:

rewrite "^/2007/.+$" / break;
share|improve this answer
    
Thanks! That did the trick. –  Delameko May 6 '10 at 10:40
    
You should not, though, that this creates two URIs for your content, whereas if you use the permanent flag instead of break then you get a 301 redirect. –  Martin Fjordvald May 6 '10 at 10:49
    
You're right, this would be better: rewrite "^/2007/.+$" / permanent; –  Guillaume Filion May 6 '10 at 12:31
add comment

Your Answer

 
discard

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.