Skip to content

Instantly share code, notes, and snippets.

@wendal wendal/gist:2359053

Created Apr 11, 2012
Embed
What would you like to do?
nginx二级域名自动匹配为子文件夹(通过rewrite)
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
server {
listen 80;
server_name nutz.cn *.nutz.cn;
set $sub_domain "";
if ($http_host ~ "(.+).nutz.cn$") {
set $sub_domain $1;
}
if ($http_host = "www.nutz.cn") {
set $sub_domain "";
}
if ($sub_domain != "") {
rewrite /(.+) /$sub_domain/$1 break;
}
location / {
root html;
index index.html index.htm;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.