Redirecting via 301 subdomain to URI/URL configuration error in NGINX

Trying to get a simple subdomain redirect in NGINX to a URI/URL path. At this point I want to get nginx.somedomain.com to redirect permanently to nginx.somedomain.com/sample/redirection.html. The config below I have in the nginx.conf file but isn't working. I've restarted the server, but still no go. Specifically it errors out and shows this as invalid in the nginx.conf file. Where should this go and also is this even correct?

server {
  server_name  nginx.somedomain.com;
  rewrite ^(.*) http://nginx.somedomain.com/sample/redirection.html permanent;
}

Thanks for any assist!

0
задан 14 July 2016 в 21:52
1 ответ

Следуйте рекомендациям и используйте директиву return:

server {
        server_name nginx.somedomain.com;
        return 301 http://nginx.somedomain.com/sample/redirection.html;
}
3
ответ дан 4 December 2019 в 12:23

Теги

Похожие вопросы