Handling many redirects

Hi.

I need to migrate a site to a new URL scheme.
Each page have a different url, and I want the old url to be still
accessible, but redirected (with a 301 HTTP status code) to the new url.

With the rewrite module I can write (at server context):

rewrite /old_url1 /new_url1/ permanent;
rewrite /old_url2 /new_url2/ permanent;

The site does not have many pages, but is this efficient?

Thanks Manlio P.

On Sun, Jan 06, 2008 at 09:00:47PM +0100, Manlio P. wrote:

The site does not have many pages, but is this efficient?

If you rewrite full URLs but not prefixes, then it’s better to use map:

   map   $uri          $new {
         default       "";
         /old_url1     /new_url1/;
         /old_url2     /new_url2/;
         ...
   }

   server {

        location / {
            if ($new) {
                rewrite  ^   $new  permanent;
            }

            ...
        }