nginx.conf server{ listen 80; server_name www.demo.com demo.hamm.cn; index index.php index.html; root /home/wwwroot/demo.hamm.cn/; include enable-php.conf; location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?
server{
listen 80;
server_name www.demo.com demo.hamm.cn;
index index.php index.html;
root /home/wwwroot/demo.hamm.cn/;
include enable-php.conf;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /.well-known {
allow all;
}
location ~ /\.
{
deny all;
}
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
}
access_log off;
}
index.php
// 访问URL http://demo.hamm.cn echo $_SERVER['HTTP_HOST']; //输出demo.hamm.cn echo $_SERVER['SERVER_NAME']; //输出www.demo.com
