user160108
user160108

Reputation: 920

nginx 301 redirects

have recently changed the url structure of my website and have added a few redirects in nginx.

Since we are focussing on SEO the urls have changed over the past week, but google has cached some of the old urls already. I have added a redirect for most of the pages but not sure if this is the right syntax

I need to redirect something like

website.com/city/restaurants/suburb/name-ID to website.com/city/suburb/name-ID and want to get rid of the /restaurants/

Upvotes: 0

Views: 1725

Answers (1)

Oroboros102
Oroboros102

Reputation: 2254

Nginx has great rewrite module. Read docs. Something like that should work for you.

rewrite  ^/(.*)/.*/(.*)/(.*-.*)$  /$1/$2/$3;

You can put it in your server caluse.

Also, you can put it inside location or if clause (still, better no to use if).

Upvotes: 1

Related Questions