Last Updated: February 25, 2016
· maxcnunes

Redirect a page with nginx

Add this into your conf file (e.g., sudo nano /etc/nginx/conf.d/

rewrite YOUR_OLD_URL YOUR_NEW_URL permanent;

For example, redirect the page br.html to the base url:

server {
    listen 80;


    location / {
        proxy_pass http://localhost:8000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;

        rewrite /br.html / permanent;

In my case this redirect was parmanent, but you could change to permanent key word to redirect if it is just temporary.