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

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...