One day last week all the forms on my ecommerce website stopped working (which most importantly meant the checkout didn't work). My site is written in XHTML and PHP. I had made no changes to the code of the site so assumed my web host had made some changes to my hosting set-up. They are pretty hopeless anyway and told me they had changed nothing and suggested the code on my site was at fault.
I currently use the following code in my htaccess file to remove the php extension to my webpage addresses (I'm afraid I don't really understand this code I just copied and pasted it from the internet, but it has seemed to work):
# Remove the need for php extension to web page addresses
RewriteCond %{REQUEST_URI} ^(.*[^/])/?$
RewriteCond %{DOCUMENT_ROOT}%1.php -f
RewriteRule .+ %1.php [QSA,L]
After working through the error I realised that for no apparent reason all my URLs now have trailing slashes added to them. This meant that the form data, sent via POST, wasn't passed through to the next page as the form pointed to a webpage without a trailing slash. I have fixed my site temporarily by simply adding a trailing slash to the address to which my forms point.
I am not happy with this solution however as I would like my webpages back how they were - without a trailing slash. Particularly I am concerned about the effect on SEO work as I know a page with and without a trailing slash is considered a different page entirely. The strangest thing is that if I create a new page it has no trailing slash even if it is identical to an old page.
I wonder if anyone has any idea why this change has occurred out of the blue and how I might go about solving this problem. My web hosting currently runs PHP version 5.2.17.
That sounds like Apache's mod_dir module might be acting up; adding trailing slashes to URLs is a key feature of that module: http://httpd.apache.org/docs/2.0/mod/mod_dir.html
You can put DirectorySlash Off in a .htaccess file and see if that works. RewriteOptions AllowNoSlash might also get you somewhere.
Alternatively, RewriteLog "rewrite.log" and RewriteLogLevel 3 directives will give you more information about the rewriting, something may be going on there.
DirectorySlash Off to my htaccess file has done the trick - sam8perry 2012-04-05 23:43