Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

Subdomain Rewrites

$
0
0
Hello there

I'm running nginx/0.7.62 on a Ubuntu box.

We've recently changed domain names.

I've got 2 wildcard DNS entries setup pointing at the server

*.subdomain.domainA.com and *.subdomain.domainB.com

I can't quite figure out how to redirect all the traffic from *.subdomain.domainA.com to *.subdomain.domainB.com whilst passing the same value for * onto the new redirect.

Can someone tell me whats wrong with the following code?


server {
listen 80;
server_name ~^(\w+)\.subdomain\.domainA\.com$;
location / {
rewrite ^(.*) http://$1.subdomain.domainB.com$request_uri permanent;
}
}

It currently redirects anything.subdomain.domainA.com to .subdomain.domainB.com

So that suggests (\w+) is not being described by $1. I think I've got a mixture of different versions syntax going on.

Any help, as always, greatly appreciated.

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>