简体   繁体   中英

404 error page redirect to home page using htaccess

I need to redirect 404 error page to home page.

I used below code to redirect 404 page to home page but this code working in one scenrio.

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ /index.php [L]

It's working for www.domain.com/slug1 this type of URL

But it's not working for www.domain.com/slug1/slug2/slug3.... this type of urls.

Please suggest any solution for this issue.

Try this

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . / [L,R=301]

ErrorDocument 404 /index.php

Look Here For More Help

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