nginx subdomain rewrite
If you meant redirect, then:
server { server_name ~^(.*)\.example\.com$ ; rewrite ^ http://www.example.com/keyword.php?keyword=$1 redirect;}
In the case of rewrite then simply do
server { server_name example.com ~^(.*)\.example\.com$ ; rewrite ^ /keyword.php?keyword=$1 break;# location /keyword.php {# ....# }}
rewrite ^/list-c-([0-9]+)-k-(.+)-o-1\.html$ /index.php?module=Default&action=List&c=$1&k=$2&o=1 last;rewrite ^/list-c-([0-9]+)-k-(.+)-o-1-p-(.+)\.html$ /index.php?module=Default&action=List&c=$1&k=$2&o=1&p=$3 last;rewrite ^/list-c-([0-9]+)-k-(.+)-o-1-price-(.+)\.html$ /index.php?module=Default&action=List&c=$1&k=$2&o=1&price=$3 last;rewrite ^/list-c-([0-9]+)-k-(.+)-o-(.+)-p-1\.html$ /index.php?module=Default&action=List&c=$1&k=$2&o=$3&p=1 last;rewrite ^/list-c-([0-9]+)-k-(.+)-o-(.+)-p-(.+)\.html$ /index.php?module=Default&action=List&c=$1&k=$2&o=$3&p=$4 last;
If it's possible I'd only create 1 server(virtual host) which is the normal domain.com
/www.domain.com
and then use the conf to rewrite the rest to them
server { server_name domain.com www.domain.com; # normal handling for files}server { server_name ~(?<subdomain>[^\.]*).domain.com; location / { try_files keyword.php?keyword=$subdomain =404; }}
please tell me if I missed something.