Welcome! Log In Create A New Profile

Advanced

Re: Regex for rewrite of subdomains

All files from this thread

File Name File Size   Posted by Date  
smime.p7s 6 KB open | download GreenGecko 02/14/2013 Read message
February 15, 2013 01:22AM
On Feb 15, 2013, at 9:48 , Darren Pilgrim wrote:

> 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;
> }
> }

Oh, NO!

server {
server_name ~^(?<KEYWORD>.+)\.domain\.com$;
return 301 http://domain.com/script.php?query=$arg_query&sub=$keyword;
}

Or if the server may process something expect "query":

server {
server_name ~^(?<KEYWORD>.+)\.domain\.com$;

if ($arg_query) {
return 301 http://domain.com/script.php?query=$arg_query&sub=$keyword;
}
...
}


--
Igor Sysoev
http://nginx.com/support.html

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

Regex for rewrite of subdomains

etrader February 14, 2013 05:05PM

Re: Regex for rewrite of subdomains Attachments

GreenGecko February 14, 2013 05:52PM

Re: Regex for rewrite of subdomains

Darren Pilgrim February 15, 2013 12:50AM

Re: Regex for rewrite of subdomains

Igor Sysoev February 15, 2013 01:22AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 216
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready