1、nginx要编译rewrite模块,不然在nginx.conf配置文件中将出现 unknown directive "rewrite" 。
下载nginx-0.8.9.tar.gz、pcre-8.12.zip、openssl-0.9.8k.tar.gz(我这用到了443端口,不需要的可以不用编译)。
编译命令:
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-pcre=/root/lib/pcre-8.12 --with-openssl=/root/lib/openssl-0.9.8k --with-http_ssl_module
不明白编译含义的可以 ./configure --help一下,里面有详细的说明。
然后 make & make install (耐心等待)
2、
server{
listen 80;
server_name k.wps.cn kuaipan.cn kuaipan.net kuaipan.com.cn www.kuaipan.net xlive.wps.cn www.kuaipan.com.cn;
rewrite ^/(.*)$ http://www.kuaipan.cn redirect;#正则式你也奥替换的内容,redirect重定向。
}
server{
listen 80;
server_name www.kuaipan.cn;
# 这里是你的业务配置
}