Not sure if this is a bug in this project, or a Magento2 bug itself
The question is site is configured to use store code in urls, and that's working fine… but urls without any store code are loading too, causing SEO problems due to content duplicity
Example: "en" is the store code of default storeView
http://ourproject.com/home -> loads fine
http://ourproject.com/en/home -> loads fine
http://ourproject.com/home should redirect 301 to http://ourproject.com/en/home
Any ideas about how to force (in a clean way) any url to use store code of default storeView?
update
We use Apache as webserver
Best Answer
We finally solved this with a light module, using controller_action_predispatch event
This assumes a site with 2 store views, with following store codes
etc / frontend / events.xml
Observer / ForceStorecodeRedirectObserver.php