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

I'm migrating an old site to a new structure, and have a bunch of these type rewrites:

location / {
 rewrite ^/foo.html /legacy-page? permanent;
 rewrite ^/bar.html /legacy-page? permanent;
 rewrite ^/org.html /legacy-page? permanent;
 rewrite ^/directory/foo.html /legacy-page? permanent;
 rewrite ^/directory2 /legacy-page? permanent;
 try_files $uri $uri/ /index.php?q=$uri&$args;
}

Is there a better / more efficient way to handle those /legacy-page rewrites?

share|improve this question

1 Answer 1

Try:

rewrite ^/(foo|bar|org|directory/foo).html /legacy-page? permanent;
rewrite ^/directory2 /legacy-page2 permanent;
share|improve this answer
    
Thanks, cjc. is there a directory equivalent? that is every request to /directory2 , /directory3 , /etc. goes to /legacy-page? and - was the second rule destination (legacy-page2) a typo? –  jimg Feb 2 '12 at 23:24

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.