millermedeiros / crossroads.js

JavaScript Routes
http://millermedeiros.github.com/crossroads.js/
1.44k stars 156 forks source link

Optional segments at the beginning of route #120

Open milutinovici opened 9 years ago

milutinovici commented 9 years ago

For example this pattern: ':language:/blog/post/{id}' is matched when language is part of url 'en/blog/post/1' but if language is ommited, (which would be equivalent of using the default language) 'blog/post/1' the route isn't matched.

corintho commented 9 years ago

Not sure how this is going to be handled here, but on every other routing framework I've seen out there, any optional path parameters were only allowed in the end of the URL

Standa666 commented 9 years ago

we are using similar doubled route for similar case ':language:/blog/post/{id}' and '/blog/post/{id}' where both triggers same target. But be prepared for shuffled arguments.

AhtiAhde commented 9 years ago

Each URI should represent a single unique resource; now you duplicate the unique resource and this will hurt your search engine visibility.

The correct philosophy would be to have the route as '/blog/post/{id}?:language: or if you do not like GET parameters, you could have '/blog/post/{id}/:language:'

I believe Google Bot tries to discover get parameters (or path) regarding language, just like it does with paginated contents. If these are easily discoverable, the Google Bot will kind of reward you, since you will get less penalties for having similar looking pages with similar link structures at the content area.