2

So my question is half oriented SEO half technical : I have a lot of links to redirect and instead of doing them one by one I was asking my self :

Is there a way to write a rewrite rule like that (this is pure fiction and not usable on nginx)

rewrite /america/(.*)/ http://www.example/nort-america/$1/ permanent;
if 500 rewrite /america/(.*)/ http://www.example/south-america/$1/ permanent;

So the idea is to redirect to a specific link and if the redirection fail try an other link.

Is this possible and moreover is this SEO friendly ?

6
  • 1
    After redirect browser will go to new url and you will never know if it gets 500 or not.
    – Alexey Ten
    Mar 29, 2016 at 13:30
  • @AlexeyTen So there is no way to check if the output of a rewrite rule is an error 500 or not ?
    – Baldráni
    Mar 29, 2016 at 13:38
  • Do you need rewrite or redirect?
    – Alexey Ten
    Mar 29, 2016 at 13:50
  • Rewrite since it is changement due to new version of a website and I need them to be done for SEO purpose.
    – Baldráni
    Mar 29, 2016 at 13:53
  • You should use proxy_pass instead
    – Alexey Ten
    Mar 29, 2016 at 15:44

1 Answer 1

1

You cannot achieve what you want with nginx only.

I would make a script in PHP or similar language, which would decide which redirect to send to the browser. If no redirect needs to be sent, then it would send the actual page itself.

You can also make the script to try to fetch alternative options with curl, however that generates unneeded traffic on the website and slows down sending the redirect.

1
  • Well I've decided to do it by routing finally (with Laravel). I could link the routing as soon as I've finished so you have an Idea
    – Baldráni
    Mar 30, 2016 at 8:05

Not the answer you're looking for? Browse other questions tagged .