A missing forward slash.

Posted in Uncategorized at 7:34 am by Toby

I’ve been having some trouble again recently with a website I did for a client. This problem had reared its head before, and I could never pin down what was causing it until recently.

The problem is when at a certain point visitors to a site start viewing the non ‘www’ version of your site so

visitor goes to www.mycoolsite.com/shop/buysomething.php

and then later they arrive at


This isnt a huge issue except that it messes up cookies and lots of shopping carts are based on cookies. So the user gets to the check out and finds that there is no longer anything in their cart. Now I noticed this early on and tried to take steps to prevent it, but it has reared its head, and for reasons I wont go into, this time I had to track down the cause. And I finally did. A missing forward slash!

If you make a link to a directory (relative or absolute) without a trailing / it will redirect to the www less version of the url, so

www.mydomain.com/shop will load mydomain.com/shop/index.php
www.mydomain.com/shop/ will load www.mydomain.com/shop/index.php

now usually there is no difference, but in certain circumstances this can mess up things like cookies. So dont let it catch you out.

The origional answer I found is here.


I admit a weather-watch website is rather an obscure place

Comments are closed.