2

I am curently using nginx and I am trying to redirect all request on http://vhost.domain.com to http://vhost.domain.com/world

I've browse some sites but I am too rookie with rewrite to obtain a nice result, could you please gimme me some help?

PS: This is what I've tried for last:

location = /world {
  rewrite ^ http://vhost.domain.com$uri permanent;
}

Kind Regards,

Half

1

Try it like this:

location /world/ {
rewrite ^/(.*)$ http://vhost.domain.com/world/$1 break;
}

The nginx rewrite syntax is like:

rewrite regexp replacement [flag]

For more info, take a look at here. And also do some research about Regular Expressions. ;)

1

Don't have to use any location, just write the below rewrite directly within server.

    rewrite  ^/$  http://vhost.domain.com/world  permanent;      
  • This rewrite looks good but when I applied it I have in my- navigator Erreur 310 (net::ERR_TOO_MANY_REDIRECTS) : Trop de redirections – Half Jan 4 '13 at 10:00
  • I guess it should be "^/$" instead of just "/", since the first param is a regexp. – cnst Jan 4 '13 at 18:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.