How to show search results in 404 page?

1 Monat weitere
We used to delete products that went out of stock. Now we know that was not wise.
We now unpublish the product so we get a better page instead of the 404 page.

But for the deleted products we would like to show some search results on the page.
For example, this URL is no longer available: /finnabair-art-alchemy-opal-magic-wax-green-brocade and it will show the 404 page.
We would like to show the search results of /search?q=finnabair+art+alchemy+opal+magic+wax+green+brocade
So basically the '-' in the URL are replaced by '+' and added as a query string to the search URL.

How to do this? I have some HTML and C# skills so I can make the changes when I know where to look for.
1 Monat weitere
It's not clear to me why you want to see + rather than -
Additionally, I'm not sure that a + would be visible in the URL, or would be come URL-encoded.

Note that if you Deleted a product in the Admin Product Edit page, then it's a "soft" delete.  The record still exists in the Product table with the Deleted column value = 1.  With a tool like SSMS, you can set it back to 0.  E.g.
UPDATE Product SET Deleted = 0 WHERE Id = n

Also, the Admin Product Edit page, has an SEO section where you can enter a new "Search engine friendly page name".  (Otherwise it will default to using "-" char in product name.)
1 Monat weitere
pmeems wrote:
We used to delete products that went out of stock. Now we know that was not wise.
We now unpublish the product so we get a better page instead of the 404 page.

But for the deleted products we would like to show some search results on the page.
For example, this URL is no longer available: /finnabair-art-alchemy-opal-magic-wax-green-brocade and it will show the 404 page.
We would like to show the search results of /search?q=finnabair+art+alchemy+opal+magic+wax+green+brocade
So basically the '-' in the URL are replaced by '+' and added as a query string to the search URL.

How to do this? I have some HTML and C# skills so I can make the changes when I know where to look for.


You need to do some customization for that using C# & Html
check CatalogController for that...front side controller

there are action for that