Created
April 11, 2012 12:32
-
-
Save wendal/2359053 to your computer and use it in GitHub Desktop.
nginx二级域名自动匹配为子文件夹(通过rewrite)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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