All urls require slash
I have a client who is frustrated because whenever he goes to his site, he has to type in the www. So I used htaccess to forward http://example.com to the www version, but that didn't work for him. He kind of forgot about it so I didn't worry about it. Now he has come to me saying that when a link goes to a directory, ie example.com/directory, it has to have a trailing slash on it, or it doesn't work. Whenever I go to the website, I don't have to type the www, or have a trailing slash on directories to navigate around. Now he's asking me to add a trailing slash to all the links on the site, which has over 5000 pages. No way.
Do you know what could be causing this (either on the server, or the client)? It is completely beyond me. It's a linux server, but I don't know which flavor.
Abhishek Reddy posted this at 07:11 — 2nd March 2007.
He has: 3,348 posts
Joined: Jul 2001
Odd. What did you add to the access file?
teammatt3 posted this at 13:50 — 2nd March 2007.
He has: 2,102 posts
Joined: Sep 2003
I deleted the access file when he told me that it still didn't help him. But here's what I used
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^example.com [nc]
rewriterule ^(.*)$ http://www.example.com/$1 [r=301,nc]
I should mention I am only a few miles away from him, so if I need to go to his office I can.
andy206uk posted this at 16:07 — 2nd March 2007.
He has: 1,758 posts
Joined: Jul 2002
Normally I would say it's the server being strange, but you say it works ok for you. Get him to try another browser maybe?
Renegade posted this at 22:10 — 3rd March 2007.
He has: 3,022 posts
Joined: Oct 2002
Excuse my negativity here (just read http://www.rinkworks.com/stupid/cs_abuse.shtml) but, it may be a good idea to visit your client.
pr0gr4mm3r posted this at 19:55 — 4th March 2007.
He has: 1,502 posts
Joined: Sep 2006
This is what I have in my .htaccess files to perpend the www & append the '/'. Hope this helps!
RewriteEngine On
# RewriteBase /
# add ending slash if needed
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule (.*) http://%{HTTP_HOST}/$1/ [R=301,L]
# prepend 'www' if needed
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.