Seeking Advice on Redirect Configuration in Epi for Defaulting to Home Page on 'Bad' URLs

75 views Asked by At

I'm currently in the process of building a site and encountering challenges with the redirect configuration. I've noticed that some platforms automatically default to the home page when entering an incorrect URL.

However, in Epi, it results in a blank page with the message 'The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.'

Is there a way to configure Epi to redirect 'bad' URLs to the home page? For example, typing 'example.com/broken' would lead to https://www.example.com/. Such a change would significantly expedite the setup of redirects.

I'm aware that Epi doesn't have a built-in feature for this situation. I'm exploring the possibility of a custom implementation where, in my multi-site application, a property URL is set to the home page. If a page is not found, it would redirect to the home page.

Any insights or solutions you could share would be greatly appreciated!

2

There are 2 answers

0
Stefan Holm Olsen On

You could use the core ASP.NET approach to this. Most times I would use the ReExecute extension method to render the error page on the failed URL.

In your case, redirecting non-existent, unpublished or expired pages, you could use the Redirect extension method.

Take a look at this https://learn.microsoft.com/en-us/aspnet/core/fundamentals/error-handling?view=aspnetcore-8.0#usestatuscodepageswithredirects

If you have a single site, single language solution, then it is easy. If you have more sites and/or languages then you need to customize the logic, using UrlResolver and ContentReference.StartPage.

0
Farhin Shaikh On

There's an open source package named Geta/404 Handler that is widely used to handle this