title: nginx Redirect subfolder to root domain
body: <p>I want to redirect the subfolder and all contents to root domain.</p>
  
  <p>For example:</p>
  
  <p><a href="http://www.example.com/ubb/" rel="nofollow noreferrer">http://www.example.com/ubb/</a> will redirect to <a href="http://www.example.com" rel="nofollow noreferrer">http://www.example.com</a></p>
  
  <p>My server configuration is like below:</p>
  
  <pre><code>server {
      listen 80 default_server;
  
      root /home/vishant/devcenter/wava-v1.1/HTML;
      index index.html index.htm;
  
      # Make site accessible from http://localhost/
      server_name baetter.l;
  
      location / {
              # First attempt to serve request as file, then
              # as directory, then fall back to displaying a 404.
              try_files $uri $uri/ =404;
              #proxy_pass         "http://127.0.0.1:3000";
              # Uncomment to enable naxsi on this location
              # include /etc/nginx/naxsi.rules
      }
  
  }
  </code></pre>
  
  <p>i have found similar problem solved using htaccess <a href="https://stackoverflow.com/questions/24630242/redirect-subfolder-to-root-domain">here</a></p>
  
  <p>But how can i achieve in nginx??</p>