rewrite url segment staging site and live site

caleboconnell nginx-forum at nginx.us
Wed Jun 13 14:31:02 UTC 2012


That's exactly what I thought, but when I used (.*) at the end and used
the $1 I kept getting 404.  When I made it the way it is now, it worked
on my staging site as  expected but not on my live site.

I can confirm that on neither site, the following does not work (404
error):

  location /old {
    rewrite ^/old/(.*)$ /new/$1 permanent;
  }

the following will redirect anything from old to the landing page for
the new section

  location /old {
    rewrite ^/old? /new permanent;
  }


here is the current config, with prior rewrites before this location
block:

location / {
    index index.php;
    try_files $uri $uri/ @ee;
  }

  location @ee {
    rewrite ^(.*) /index.php?/$1 last;
  }

  location /old {
    rewrite ^/old? /new permanent;
  }

I tired to use (.*) and $2 in hopes that the prior $1 wasn't breaking
it.  Still no luck.

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,227464,227496#msg-227496



More information about the nginx mailing list