Gospel. Culture. Technology. Music.


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

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Powered by WordPress & Theme by Anders Norén