Nginx下实现 将123.com转发到www.123.com 并且访问时显示www.123.com的方法:
配置如下:
server {
listen 80;
server_name 123.com www.123.com;
root /data/test;
index index.htm index.php index.html;
if ($host ~* "^123.com" ) {
rewrite "^(.*)$" http://www.123.com$1 permanent;
rewrite "^/(.+/)*(\?.+)*$" http://www.123.com/$1$2 permanent;
}
location ~ .*\.(php|php5)?$
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
access_log /data0/logs/localhost.log access;
}