You might happen to have a WordPress blog whose URLs you need to rewrite, perhaps because you've changed category
to topic
and you don't want to lose that sweet search engine traffic.
Here's a quick way to do it with nginx
:
- Open your site's configuration in your favorite text editor:
sudo nano /etc/nginx/some.site
- Look for the the
location
block, it looks similar to this:location / { try_files $uri $uri/ =404; }
- Add the
rewrite
directive:location / { rewrite ^/category(.*)$ /topic$1 permanent; try_files $uri $uri/ =404; }
This redirects all /category
requests to /topic
.
That's it!