产品服务AMH 免费服务器主机面板SSL证书 免费SSL证书申请编程助手免费智能写代码、翻译NewAMYSQL 免费MySQL管理工具AMFTP 免费FTP管理客户端

AMH 社区首页

 AMH社区 - 开放自由有价值的社区

[求助帖] 为什么自建的404.php不能实现呢

life169
铁牌会员
151.00 价值分

life169 发表于 2013-09-16 10:45:23
请教 A大, 我想在根目录下建一个404.php, 当发生404错误时就指向 /404.php

我在 xxx.conf 里 把 error_page 404 /ErrorPages/404.html; 改成:error_page 404 /404.php;
重启nginx

测试了一下,404错误依然指向 /ErrorPages/404.html; 而不是我的/404.php

请问这是什么原因呢? 要怎么改才能实现我的要求呢??

评价: 这个问题有价值吗?  没有 (0分)   有, 感谢 (0分)
2013-09-16 10:45:23 1

isha
银牌会员
2907.00 价值分

你确定修改了并重启了吗?
评价: 这个答复有价值吗?  没有 (0分)   有, 感谢 (0分)
回复  2013-09-16 14:35:40 2

isha
银牌会员
2907.00 价值分

有些时候他会默认覆盖你的修改设置你最好是到ssh下修改重启看看
评价: 这个答复有价值吗?  没有 (0分)   有, 感谢 (0分)
回复  2013-09-16 14:36:08 3

yun
银牌会员
1276.20 价值分

没改成功。
评价: 这个答复有价值吗?  没有 (0分)   有, 感谢 (0分)
回复  2013-09-16 14:46:35 4

amysql
创始人
99532.51 价值分

把 conf配置贴出来看看。
评价: 这个答复有价值吗?  没有 (0分)   有, 感谢 (0分)
回复  2013-09-16 16:34:34 5

AMH面板 - 好用高效低占用、安全可靠极稳定

life169
铁牌会员
151.00 价值分

server
{
listen 80;
server_name 7hom.com www.7hom.com *.7hom.com; #server_name end
index index.php index.html index.htm; #index end

set $subdomain '';
if ( $host ~* "(?:(\w+\.){0,})(\b(?!www\b)\w+)\.\b(?!(com|org|gov|net|cn)\b)\w+\.\w+" ) { set $subdomain "/$2"; }
root /home/wwwroot/7hom.com/web$subdomain;
include rewrite/amh.conf; #rewrite end

#error_page
error_page 404 /404.php;
error_page 502 /ErrorPages/502.html;
location ~ /ErrorPages/(400|401|403|404|405|502|503)\.html$
{
root /home/wwwroot/7hom.com/web;
}
#life169 write the code down------
if ($host ~* "www.7hom.com") {
rewrite ^/(.*)$ http://7hom.com/$1 permanent;
}
#life169 wirite the code up-------

location ~ .*\.php$
{
fastcgi_pass unix:/tmp/php-cgi-7hom.com.sock;
fastcgi_index index.php;
include fcgi-host.conf;
fastcgi_param DOCUMENT_ROOT /web$subdomain;
fastcgi_param SCRIPT_FILENAME /web$subdomain$fastcgi_script_name;
}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp3|wma)$
{
expires 30d;
}

location ~ .*\.(js|css)$
{
expires 12h;
}

access_log off; #access_log end
error_log /dev/null; #error_log end
}
评价: 这个答复有价值吗?  没有 (0分)   有, 感谢 (0分)
回复  2013-09-16 18:04:21 6

life169
铁牌会员
151.00 价值分

请 知情人告知
评价: 这个答复有价值吗?  没有 (0分)   有, 感谢 (0分)
回复  2013-09-16 18:04:53 7

life169
铁牌会员
151.00 价值分

改了之后 重启nginx 后,找一个本站不存在的网址检验,出来的仍然是默认的404的页面,而不是我做的那个页面
评价: 这个答复有价值吗?  没有 (0分)   有, 感谢 (0分)
回复  2013-09-16 18:06:25 8

yun
银牌会员
1276.20 价值分

Bad Request (Invalid Hostname)
评价: 这个答复有价值吗?  没有 (0分)   有, 感谢 (0分)
回复  2013-09-16 18:10:23 9

l12ab
金牌会员
7345.06 价值分

error_page 404 /ErrorPages/404.php;
error_page 502 /ErrorPages/502.php;
location ~ /ErrorPages/(400|401|403|404|405|502|503)\.php$
{
root /home/wwwroot/7hom.com/web;
}
评价: 这个答复有价值吗?  没有 (0分)   有, 感谢 (0分)
回复  2013-09-16 20:56:10 10
 1 2 >  (总2页)
AMH社区列表
用户服务中心