I have quite a few mappings to do before the holidays, but I'm worried about all the not founds that will occur when people click on existing links using the old names (from google, etc.). I know I can update .htaccess with proper 301 redirects, but there will be a large number and I would rather not have to do that (risk, maintenance, performance, etc.). I see that the original product name is saved on the database as original_name. I am thinking about adding some code to the Not Found/404 else in products.php to do the following:
If not found
- Query products table against the original_name using $q
- If a match is found - redo all the original code under "if($q)" using the mapped name from the found row (replace $q)
- Show the mapped page to the user, but send the 404 code to remove it from the index
- If no match is found, then do normal 404 logic
Do you see issues with this? Is the original_name column normalised the same way the normalised_name column is and would the new select work correctly? I don't even see where these columns are populated in the first place. Do you have any other ideas for this? Do you think it's worth it to do this or should I just let the normal 404 logic handle it?
If I instead add the 301s to .htaccess, could I remove them after a while or would they need to stay in place forever?
Confused! Thank you for any suggestions.