How to: Redirect an URL in NGINX
How to: Redirect an URL in NGINX
One might need to redirect to another URL in a number of scenarios. I will cover two examples for scenarios I have come across and how I addresses those issues:
I. Redirect from a naked domain to the www subdomain:
server {
listen 80;
server_name test.com;
return 301 $scheme://www.test.com$request_uri;
}
II. Redirect an Exchange Server Autodiscover subfolder to another domain:
#Redirect Autodiscover Requests
location ~* ^/Autodiscover
{
# proxy_pass https://outlook.office365.com:443;
# proxy_cache_bypass 1;
return 301 $scheme://outlook.office365.com$request_uri;
}
For this last example you can chose 1 of two approaches: The first one which is commented out does a proxy to your Exchange Server AutoDiscover service. The problem with this approach is that you need to have the correct SSL certificate for your domain installed or you will have a number of warnings thrown out at you. This approach is useful if you want to cache responses, etc. My recommended approach is the one that is not commented out which is a normal redirect as the one you saw in the first example. Doing a redirect like this will avoid having Outlook trying to hit your server every now and then to check for the AutoDiscover directives. This is useful if you are hosting your domain in a non-exchange server host (you lack the AutoDiscover folder there).
Love
Can we use Let's Encrypt, the free and open certificate authority?
Hola! gracias por la info, me sirvió el comando sacandole el nombre del server. En mi caso, fue una migración…
Yes 3rd option helped me too. I removed the WC key Values from config file then started working.
I know this is from 2014. But really, thank you!