简体   繁体   中英

404 error page not redirected to custom page using htaccess

My htaccess rule to redirect 404 error to custom page isn't working. I put the below code:

<IfModule security2_module>
    ErrorDocument 404 https://example.com/404.php
    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /
    RewriteRule index\.html$   index.php [L]
</IfModule>

And I used both - ErrorDocument 404 https://example.com/404.php & ErrorDocument 404 /404.php

Pls let me know if anyone have solution

ErrorDocument 404 http://jobguide.australianenglishcenter.com/404/

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} ^/404/$
RewriteRule ^(.*)$ <YourRelativePathToPHPFile>/404.php [L]

Here,The ErrorDocument redirects all 404s to a specific URL

The Rewrite rules map that URL to your actual 404.php script. The RewriteCond regular expressions can be made more generic if you want, but I think you have to explicitly define all ErrorDocument codes you want to override.

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