Friday, November 27, 2015

Nginx rewrite rule (subdirectory to subdomain)



I would like to redirect admin subdirectory to a subdomain. I tried to create this rule for Nginx however it's not working:



location ^~ /admin/ {
rewrite ^/admin(.*) http://admin.example.com$uri permanent;
}



Thank you
Regards


Answer



Something like this should do the job:



location ^~ /admin/ {
rewrite ^/admin/(.*) http://admin.example.com/$1 permanent;
}


No comments:

Post a Comment