[英]Wordpress 404 works for non existing page but not for non existing images
http://localhost/wordpress/not-found-page.php =>
轉到404
找不到頁面http://localhost/wordpress/not-found-image.png =>
轉到服務器404
錯誤頁面
我已經在.htaccess
添加了此代碼
ErrorDocument 404 /index.php?error=404
以下是當前的.htaccess文件
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
請指導。
如果存在,請從您的配置中刪除“ fastcgi_intercept_errors”參數。 由於'error_page'聲明404錯誤,因此沒有必要,該錯誤應由index.php處理,這將觸發PHP-FPM進行處理,而WordPress則可以顯示您主題的404頁面。
如果這不起作用,則:
在.htaccess中添加以下內容:
RewriteCond %{REQUEST_URI} \.(jpg|jpeg|gif|png|ico)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .*$ /index.php?error=404 [R]
如果不存在,這會將png / jpeg / gif / ico文件重定向到/index.php?error=404
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.