Quantcast
Channel: Nginx Forum
Viewing all articles
Browse latest Browse all 53287

Re: Regex for rewrite of subdomains

$
0
0
On 2013-02-14 14:05, etrader wrote:
> I want to rewrite subdomains by adding a separate server for subdomains as
[...]
> keyword.domain.com/query=some to
> domain.com/script.php?query=some&sub=keyword

server {
server_name *.domain.com;

if ($http_host ~* (.+)\.domain.com$) {
set $keyword $1;
}

if ($request_uri ~* ^/query=(.+)) {
return 301 http://domain.com/script.php?query=$1&sub=$keyword;
}
}

I'm not sure a map would be faster in this case because you don't need a
multitude of patterns.

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Viewing all articles
Browse latest Browse all 53287

Trending Articles



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