主机头
标题:
nginx.cof设置2个server
[打印本页]
作者:
admin
时间:
2013-5-11 14:32
标题:
nginx.cof设置2个server
有两个server
server
{
server_name zhujitou.com;
rewrite ^(.*) http://www.zhujitou.com$1 permanent;
}
复制代码
用的amh的面板
想做301跳转
server
{
listen 80;
server_name www.xxx.net; #server_name end
index index.html index.htm index.php; #index end
set $domain '';
if ( $host ~* "(.+)\.(.+)\.(.+)" )
{
#set $domain "/$1"; #host subdirectory
}
if ( $domain = '/www' )
{
set $domain '';
}
root /home/wwwroot/xxx.net/web$domain;
include rewrite/amh.conf; #rewrite end
#error_page
error_page 400 /ErrorPages/400.html;
error_page 403 /ErrorPages/403.html;
error_page 404 /ErrorPages/404.html;
error_page 502 /ErrorPages/502.html;
location ~ /ErrorPages/(400|401|403|404|405|502|503)\.html$
{
root /home/wwwroot/xxx.net/web;
}
location ~ .*\.php$
{
fastcgi_pass unix:/tmp/php-cgi-xxx.net.sock;
fastcgi_index index.php;
include fcgi-host.conf;
fastcgi_param SCRIPT_FILENAME /web$domain$fastcgi_script_name;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp3|wma)$
{
expires 30d;
}
location ~ .*\.(js|css)$
{
expires 12h;
}
access_log off; #access_log end
error_log /dev/null; #error_log end
}
server
{
server_name xxx.net;
rewrite ^(.*) http://www.xxx.net$1 permanent;
}
复制代码
配置之后用nginx -t 测试一下配置文件,没有问题,就可以。
欢迎光临 主机头 (http://zhujitou.com/)
Powered by Discuz! X2.5