有关nginx重定向的一个例子
时间:2014-07-05 13:25 来源:linux.it.net.cn 作者:IT网
在nginx中,如果是单次重定向用 redirect, 如果永久跳转用 permanent,则用 permanent。
复制代码代码如下:
{
listen 80;
server_name xxx.com www.xxx.com;
index index.html index.php;
root /data/www/wwwroot;
if ($http_host !~ "^www.xxx.com$") {
rewrite ^(.*) http://www.xxx.com$1 permanent;
}
...
}
(责任编辑:IT)
在nginx中,如果是单次重定向用 redirect, 如果永久跳转用 permanent,则用 permanent。
复制代码代码如下:
{
(责任编辑:IT)listen 80; server_name xxx.com www.xxx.com; index index.html index.php; root /data/www/wwwroot; if ($http_host !~ "^www.xxx.com$") { rewrite ^(.*) http://www.xxx.com$1 permanent; } ... } |