How to redirect 404 page to home page?
4 Answers
Login to the admin and go to
System > Configuration > Web
and change the drop-down value for CMS No Route Page
in the Default Pages section. You should be able to select your Home Page
.
Second method by .htaccess:
For example, if you wish to redirect the 404 (File Not Found) errors to http://example.com
, you should add this line to your .htaccess file:
ErrorDocument 404 http://example.com
try:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ /index.html [L]
Or you can try like this way too,add the following code & replace YOURURL with the URL where you want the error 404 page redirected to.
ErrorDocument 404 http://YOURURL
Try this one: Note: If you have a specific 404 Url that you want to redirect to the homepage. Here's how to redirect the target path should be "../"
1. Catalog > Url Rewrite Management
2. Click Add URL Rewrite
3. Select Custom Url Rewrite
4. Add your desired 404-page link in here.
I hope this helps. Guys out there just correct me if I'm wrong. But I'm doing this one a lot in my regular tasks.
-
-
-
Yes, I'm getting error message, when I was passing my Request url and Target url.– YKBJun 7, 2018 at 10:22
-
Can you show me a screenshot of the error? Or what does the error says? And can you send me over the specific 404 page url from your site? Thanks Jun 7, 2018 at 12:02
In 404 cms page, call .phtml
file with this code. There will write a code like,
header(“HTTP/1.1 404 Not Found”);
header(“Location: /”); // Redirect to home page
exit();