Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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,


share|improve this question

2 Answers 2

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. ;)

share|improve this answer

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

    rewrite  ^/$  http://vhost.domain.com/world  permanent;      
share|improve this answer
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 posting your answer, you agree to the privacy policy and terms of service.

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