简体   繁体   中英

Apache 2.4 + PHP-FPM, how to set error page for non-existing php file

I'm currently using Apache 2.4 + PHP-FPM, everything works fine except for getting the error page for non-existing php files:

If there is a request for a non-existing php file, then I would get a response "File not found.". But what I want is to redirect that request to our error page.

Because all the php request will first go to php_fpm, so the php default error page mechanism would not work.

I tried some mod_rewrite things, but it did not work either:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/(.*\.php(/.*)?)$ /path/to/404.html [R=404,L]

ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/path/to/file/

Thanks for your help in advance!

最后,我通过添加以下内容解决了这个问题:

ProxyErrorOverride on

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM