Earlier this week i implemented the forcing of trailing slashes for some websites. And this worked out great.
But today one of the ladies here at the office noticed the contact form on one site wasn’t functioning properly anymore.
So i did some debugging and quickly came to the conclusion the POST data array was empty after a submit of the form. That’s weird i thought. And didn’t really have a clue where to start looking. The code wasn’t touched for a couple of weeks. Bu then i remembered adding the forcing of the trailing slash.
So i browsed to the contact form and did a view source. And there was the problem. The form submitted to
/contact/verstuurd
A URL without a trailing slash. This causes apache to rewrite the url to
/contact/verstuurd/
And this also seems to turn the POST into a GET request.
So to fix it just changed to URL in the form to reflect the correct end point. But i have to say i didn’t expect this to happen. I understand why it happens. And it’s pretty logical. But i wonder if there’s a way around this behavior?



Thijs Lensselink is a PHP developer, consultant and all out open source enthusiast.
He has over 12+ years of experience in building and maintaining web applications mostly
on linux/Unix/BSD platforms. Besides a full time job he does freelance work with his ...
what does your rewrite configuration look like? The fact that it rewrites using a 301 redirect is as far as I know a configuration issue.
Ivo
20 Feb 09 at 12:17
Hey Ivo,
My rewrite lines are posted below. Maybe i need to do this without a 301 response if possible?
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]
Thijs Lensselink
20 Feb 09 at 12:31
ja, je kunt vermoedelijk een RewriteCond erop zetten voor METHOD GET en dan voor post een andere set doen waarbij je de R=301 uit de regel weglaat (dus alleen [L]).
Ivo
22 Feb 09 at 04:09
Perfect. Ik heb die 301 nodig maar dat is inderdaad alleen voor GET. Nu heb ik twee rules en dat werk prima.
ty!
RewriteCond %{REQUEST_METHOD} =GET
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]
RewriteCond %{REQUEST_METHOD} =POST
RewriteRule [^/]$ %{REQUEST_URI}/ [NC,L]
Thijs Lensselink
22 Feb 09 at 08:21
Thanks for the helpful information
Download
19 Jun 11 at 03:49