Open sebastienros opened 4 years ago
Also, there is a custom tag to represent associated languages that is useful for home pages <link rel="alternate" hreflang="fr-FR"/>
as see on https://worldnomads.com
It is also necessary to make it possible to redirect to the address of the pages that are exposed in the autoroute part to the root of the site of the pages that are the main ones, since it is important for a seo site that there are no duplicate pages.
We think that the home page route must redirect (temprorarily) to the content item autoroute URL
class HomeRedirectionMiddleware
{
private readonly RequestDelegate _next;
private readonly ISiteService _siteService;
public HomeRedirectionMiddleware(RequestDelegate next, ISiteService siteService)
{
_next = next;
_siteService = siteService;
}
public async Task Invoke(HttpContext httpContext)
{
var homeRoute = (await _siteService.GetSiteSettingsAsync()).HomeRoute;
if (httpContext.Request.Path.Equals("/ua", StringComparison.OrdinalIgnoreCase))
{
httpContext.Response.StatusCode = 301;
httpContext.Response.Redirect("/");
}
await _next.Invoke(httpContext);
}
}
@sebastienros how can i get autoroute of homeroute without additional overhead ?
@Diman96 there is a service (IAutorouteEntries) that should give you that.
Maybe we could use a cookie to save the fact that it was the first time on the homepage, and then redirect to the request culture automatically. Not after, as subsequent navigation would be from explicit clicks. The cookie would be short-lived (session) so that the next visit it happens again.