Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- map $request_uri $new_uri {
- default DEFAULT;
- /shell http://shell.com;
- /lol http://lol.com;
- }
- map $request_uri $ret_code {
- default 301;
- /shell 301;
- /lol 302;
- }
- server {
- listen 80;
- server_name TestDomain.com www.TestDomain.com;
- location / {
- add_header X-request_uri $request_uri;
- add_header X-new_uri $new_uri;
- add_header X-return_code $ret_code;
- if ($new_uri = "DEFAULT") {
- return 301 https://ashfame.com$request_uri;
- }
- if ($ret_code = 301) {
- return 301 $new_uri;
- }
- if ($ret_code = 302) {
- return 302 $new_uri;
- }
- }
- }
- $ curl -I testdomain.com/lol
- HTTP/1.1 301 Moved Permanently
- Server: nginx/1.10.0 (Ubuntu)
- Date: Sun, 22 Jan 2017 20:04:06 GMT
- Content-Type: text/html
- Content-Length: 194
- Connection: keep-alive
- Location: https://ashfame.com/lol
- X-request_uri: /lol
- X-new_uri: DEFAULT
- X-return_code: 301
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement