Reputation: 626
What I would want is for me to type in test.com/path and have it go to anothersite.com, but instead, it goes to differentsite.com. I believe I'm doing the correct formatting, but seems to be skipping over the location block entirely.
server {
listen 80;
listen [::]:80;
server_name test.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443;
listen [::]:443;
server_name test.com;
location /path {
return 301 https://anothersite.com;
}
return 301 https://differentsite.com;
}
Upvotes: 0
Views: 475
Reputation: 626
It turns out that the server block should not have a return statement. There should be two location blocks with return statements for each path
server {
listen 80;
listen [::]:80;
server_name test.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443;
listen [::]:443;
server_name test.com;
location / {
return 301 https://differentsite.com;
}
location /path {
return 301 https://anothersite.com;
}
}
Upvotes: 1