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'm trying to redirect the following URL

Http://example.com/category/something

To redirect to

Http://something.example.com/category/something

Where "something" could be anything.

I've already set up nginx and Dns for wild card and confirmed that that works.

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

Where is an orthodox way:

location /category/ {
      location ~ ^/category/(?<category>.+)$ {
            return 302 http://$category.example.com/category/$category
      }
}

Without "rewrite". Tested at nginx/1.0.0

share|improve this answer
    
This worked great. –  drewrockshard Nov 7 '11 at 19:57
add comment

untested.. but should work

location / {
   rewrite  ^/category/(.*)$  http://$1.example.com/category/$1  permanent;
}
share|improve this answer
    
This didn't work - does the file or path have to exist or does nginx just route it as requested? –  drewrockshard Nov 7 '11 at 19:50
add comment

Your Answer

 
discard

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.