Skip to content

Instantly share code, notes, and snippets.

@JingwenTian
Last active January 4, 2016 04:49
Show Gist options
  • Save JingwenTian/8571390 to your computer and use it in GitHub Desktop.
Save JingwenTian/8571390 to your computer and use it in GitHub Desktop.
nginx泛域名解析实现二级域名多域名详细说明: http://www.jingwentian.com/t-34
server {
listen 80;
server_name ~^(?<subdomain>.+)\.jingwentian\.com$;
root /home/wwwroot/jingwentian/$subdomain;
index index.html index.htm index.php;
fastcgi_intercept_errors on;
error_page 404 = /404.html;
location / {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't
# break when using query string
try_files $uri $uri/ =404;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# fastcgi_param domain $subdomain;
# include fastcgi_params;
#}
location ~ .*\.(php|php5)?$ {
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment