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
Solution 1:
Something like this should do the job:
location ^~ /admin/ {
rewrite ^/admin/(.*) $scheme://admin.example.com/$1 permanent;
}