Is having two routePaths for the same target a good idea?

52 Views Asked by At

I'm migrating realurl configuration for extension news to route enhancers. The realurl configuration is a mix of fixedPostVars and postVarSets. Therefore speaking urls of news single views are build in two different ways:

Now with route enhancers I would like to have all links built without the prefix but still be able to resolve links with or without the prefix.

In my route enhancers configuration I added the following two routePaths in this exact order which seems to work just fine:

- { routePath: '/news/{news-title}', _controller: 'News::detail', _arguments: {'news-title': 'news'}}
- { routePath: '/{news-title}', _controller: 'News::detail', _arguments: {'news-title': 'news'}}

In a reversed order this is not working as links are built with the prefix. I'm wondering if the processing order of routePaths is reliable. Is using routePaths this way a good idea? Or should I better use redirects on webserver level which would be much more work?

1

There are 1 best solutions below

2
Jonas Eberle On BEST ANSWER

This should work.

If you are not redirecting you should think about duplicate content. I would check if EXT:seo is adding the correct canonical URL (which should be the first matching route) in order to make search engines are happy.

Yet I think this is a bit uncharted territory. Personally I would add a simple generic redirect to your webserver.