论坛风格切换
  • 6603阅读
  • 1回复

[nginx]nginx 重定向301和错误页面404等设置 [复制链接]

上一主题 下一主题
离线太史慈
 

发帖
766
金币
626
威望
556
只看楼主 倒序阅读 使用道具 楼主  发表于: 2011-07-20
— 本帖被 云天河 执行加亮操作(2011-07-20) —
iis 重定向301和错误页面404等设置http://phpwind.me/298.html
apache 重定向301和错误页面404等设置http://phpwind.me/299.html
nginx 重定向301和错误页面404等设置http://phpwind.me/300.html



配置404:
1。创建自己的404.html页面
2。更改nginx.conf在http定义区域加入:
  1. fastcgi_intercept_errors on;

3。更改nginx.conf(或单独网站配置文件,例如在nginx -> sites-enabled下的站点配置文件 )
中在server 区域加入:
  1. error_page 404 = /404.html

或者
  1. error_page 404 =http://www.xxx.com/404.html

4。更改后重新启动nginx,见上面步骤

#502 等错误可以用同样的方法来配置。
  1. error_page 500 502 503 504 = /50x.html;

[url=http://www.phpwind.com]phpwind[/url]
离线prisk

发帖
278
金币
0
威望
59
只看该作者 沙发  发表于: 2011-08-13
301配置

server {

    server_name www.yoursite.com yoursite.com;

    if ($host != 'www.yoursite.com' ) {

        rewrite  ^/(.*)$  http://www.yoursite.com/$1  permanent;

    }

    ...

}



方法2:

类似apache,单独给yoursite.com做一个虚拟主机

server {

    server_name  yoursite.com;

    rewrite ^(.*) http://www.yoursite.com$1 permanent;

}
[img]http://appimg.veryapp.com/pbar/img.php?barhash=4b7ee90840c62e74d81ca326e43bb302d7b460c4[/img]
快速回复
限100 字节
如果您在写长篇帖子又不马上发表,建议存为草稿
 
提到某人:
选择好友
上一个 下一个