您的位置:首页 > 运维架构 > Nginx

nginx特定的 404页面利于seo

2011-06-20 14:21 183 查看
要求:
访问http://www.qq.com/123 url保持不变 显示的结果为指定的404页面
curl -I http://www.qq.com/123 返回的状态码为404

准备一 404.php页面在最底部加上:

<?php
@header('HTTP/1.1 404 Not Found');
@header('Status: 404 Not Found');
?>

然后nginx里配置
location / {
xxxxx; ##此处表示N多的规则依据实际情况定##
rewrite ^/404.html /404.php last;
if (!-e $request_filename) {
rewrite ^(.*)$ /404.html last;
}
}

然后reload nginx即可。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  职场 seo 休闲 nginx 404