Redirect a page with nginx
Add this into your conf file (e.g., sudo nano /etc/nginx/conf.d/my_domain.com.conf):
rewrite YOUR_OLD_URL YOUR_NEW_URL permanent;
For example, redirect the page br.html to the base url:
server {
listen 80;
server_name my_domain.com;
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.
Written by Max Claus Nunes
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Nginx
Authors
reiaguilera
279.4K
jamesdullaghan
90.14K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#