Devlogs
Symfony routing, by default, seem not work with URLs with trailing slashes.
For example www.symfony-project.org/community works ok, but www.symfony-project.org/community/ results in error 404.
You can fix it easily at application level by overriding sfPatternRouting.
1 class myPatternRouting extends sfPatternRouting 2 { 3 public function parse($url) 4 { 5 $url = rtrim($url, '/'); # trim trailing slashes before actual routing 6 return parent::parse($url); 7 } 8 }
Put this code in lib directory in myPatternRouting.class.php file and don't forget to adjust your settings in factories.yml.
all:
routing:
class: myPatternRouting
param:
generate_shortest_url: true
extra_parameters_as_query_string: true
That's it.
What about duplicate contents? two urls serving the very same contents and google is grumpy. a 301 redirect should be better, but you'd have to use sfContext::getInstance() to retrieve the controller from the routing class instance: ugly.
Thanks! So much simpler than editing .htaccess...
almost 2 years ago Dmitriy http://www.infosoft.ua #0
Great! 2 hours of googling, and this is exact what i need:
1. Solved Doctrine problem with slashes at the end
2. Creating url's with slash at the end and then correctly parsing by symfony routing system
Sanks!
P.S. Solutions based on .htaccess file modification doesn't work