I'm trying to redirect a subfolder to a subdomain in nginx. I want http://example.com/~meow/ to be redirected to http://meow.example.com/. I tried the following:
location ~ ^/\~meow/(.*)$ {
rewrite ^(.*)$ http://meow.example.com$1 permanent;
}
But it doesn't work. It gets caught by my location block for user directories:
location ~ ^/~([^/]+)/(.+\.php)$ {
[...]
}
and
location ~ ^/\~([^/]+)/(.*)$ {
[...]
}
So, how would I do this? Oh, and I only want /~meow/ to be redirected. All other user directories should not be changed.
Answer
You could try using nested location
like this
location ~ ^/\~([^/]+)/(.*)$ {
location ~ ^/\~meow/(.*)$ {
rewrite ^(.*)$ http://meow.example.com$1 permanent;
}
[...]
}
No comments:
Post a Comment