Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 2nd, 2012  |  syntax: None  |  size: 0.54 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Nginx rewrite - only redirect to one domain
  2. if ($request_uri ~ "s.domain.com"){
  3.        rewrite ^ http://domain-new.com;
  4.      }
  5.        
  6. server {
  7.     listen 80;
  8.     server_name s.domain.com;
  9.     rewrite ^ http://domain-new.com$request_uri? permanent;
  10. }
  11.        
  12. server {
  13.     listen 80;
  14.     server_name s.domain.com;
  15.     # for index.xyz pages
  16.     location ~ ^/index..+$ {
  17.         rewrite ^ http://domain-new.com$request_uri? permanent;
  18.     }
  19.     # for pages with index left out
  20.     location / {
  21.         rewrite ^/$ http://domain-new.com permanent;
  22.     }
  23. }