Intelligent 404 Redirector for SilverStripe 3
An extension to add additional functionality to the existing 404 ErrorPage. If a 404 page is called, it tries to guess the intended page by matching up the last segment of the url to all SiteTree pages. It also uses soundex to match similar sounding pages to find other alternatives.
How it works
If a 404 error is detected (note: does not work in
- It will search SiteTree for all matching URLSegments, as well as any that sound the same (using PHP's soundex()).
- If 1 exact match is found, a 301 redirect is sent.
- Else if no exact match is found, and 1 similar page is found, a 301 redirect is sent to the similar page.
- Else if more than 1 exact or similar page is found, a regular 404 page is shown and the list of possible options is shown (ie: "Were you looking for one of the following pages?") directly beneath it.
- Else a regular 404 page is shown.
- SilverStripe 3+
Copy the intelligent-404 directory to the root folder of your website installation. Please note that this will only work if you website is not in development mode (ie: for testing and detecting actual 404 pages).
mysite/_config/config.yml you can optionally define different ignored ClassNames:
Intelligent404: intelligent_404_ignored_classes: - ErrorPage - RedirectorPage - VirtualPage
If you prefer not to redirect automatically if a single possible match is found, the following option will fall back to either SilverStripe's legacy redirect module, and if that fails simply provide a single possible link:
Intelligent404: redirect_on_single_match: false