Jump to content

How To 301 Redirect All 404 Missing Pages To The Homepage


mercuriuscreative

Recommended Posts

Hi,

 
I need to change how 404 redirects work.
 
I just converted this site from an old non prestashop website to prestashop.
There are a lot of old addresses which are now 404. 
 
I would like to redirect ALL 404 errors as a 301 redirect to the homepage.
 
My PrestaShop version is 1.6.1.4
 
SEO URLs are on.
 
How can this be done?
 
Link to comment
Share on other sites

Ok, I think I solved it on my own... If you're interested. (I could not find a clear example that worked)

 

Step 1--

Copy the file

/controllers/front/PageNotFoundController.php

 

Step 2--

Paste the file into:

/override/controllers/front/PageNotFoundController.php

 

 
Step 3--
Edit the file:
Right after the /* comments */ paste...
header( "HTTP/1.1 301 Moved Permanently" ); 
header( "Location: http://YOURWEBADDRESSHERE/" ); 
exit();

Step 4--

After that the rest of the code is still there. So, just save the file. 
 
Step 5--
Locate
/cache/class_index.php 
 
Step 6--
delete the file or append the filename with OLD
 
That's it. That worked for me. All missing pages now go to the homepage. 
Some people don't recommend this, and maybe it isn't the most graceful way to do this on PrestaShop, but it works for me. 
 
Let me know if you see a problem, or have some advice. 
  • Like 1
Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...