Trailing slash in Symfony route

I found several approaches to get rid of the annoying 404-error when you open a route with a trailing-slash:

www.symfonysite.com/route
>> ok

www.symfonysite.com/route/
>> Error: 404-not found

The easiest solution is to add a RewriteRule to your .htaccess:

Now all requests with trailing-slash are redirected to the one without trailing-slash.

Notice that this only works as long as you do not have any routes which want require a trailing slash, because this would lead to an redirect loop:

 

About 

Hi, I'm a Berlin-based developer and working on webstuff since 2000. My focus lies on PHP, TYPO3 and Symfony. 2009 I became a certified TYPO3-Integrator. I worked on projects for clients like Paypal, Union Investment, Commerzbank or Warsteiner.

Go check out my page http://www.christian-baer.com

Published by

Christian Baer

Hi, I'm a Berlin-based developer and working on webstuff since 2000. My focus lies on PHP, TYPO3 and Symfony. 2009 I became a certified TYPO3-Integrator. I worked on projects for clients like Paypal, Union Investment, Commerzbank or Warsteiner. Go check out my page http://www.christian-baer.com

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">