Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. map $request_uri $new_uri {
  2. default DEFAULT;
  3. /shell http://shell.com;
  4. /lol http://lol.com;
  5. }
  6. map $request_uri $ret_code {
  7. default 301;
  8. /shell 301;
  9. /lol 302;
  10. }
  11.  
  12. server {
  13. listen 80;
  14. server_name TestDomain.com www.TestDomain.com;
  15.  
  16. location / {
  17. add_header X-request_uri $request_uri;
  18. add_header X-new_uri $new_uri;
  19. add_header X-return_code $ret_code;
  20. if ($new_uri = "DEFAULT") {
  21. return 301 https://ashfame.com$request_uri;
  22. }
  23. if ($ret_code = 301) {
  24. return 301 $new_uri;
  25. }
  26. if ($ret_code = 302) {
  27. return 302 $new_uri;
  28. }
  29. }
  30. }
  31.  
  32. $ curl -I testdomain.com/lol
  33. HTTP/1.1 301 Moved Permanently
  34. Server: nginx/1.10.0 (Ubuntu)
  35. Date: Sun, 22 Jan 2017 20:04:06 GMT
  36. Content-Type: text/html
  37. Content-Length: 194
  38. Connection: keep-alive
  39. Location: https://ashfame.com/lol
  40. X-request_uri: /lol
  41. X-new_uri: DEFAULT
  42. X-return_code: 301
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement