David Westerfield

Theology. Culture. Technology.


Redirecting Only The Root URL Within NGINX


For some reason I found this rule to be difficult but finally got it to work thanks to the internets. This is the only rule that worked within the NGINX configuration to get only the root URL to redirect to (in my case) a non-SSL location. Here’s the section:

server {
  (..)
  location / {
    rewrite ^(/)$ http://www.domain.com/ permanent;
  }
}

http://stackoverflow.com/questions/9336261/nginx-rewrite-only-when-root-domain

Previous

Optimal NGINX SSL Settings

Next

Using Postfix SASL Authentication with Google 2-step Verification On

2 Comments

  1. Great Post, can i use this code in footer?

Leave a Reply

Powered by WordPress & Theme by Anders Norén