Greenguy's Board

Greenguy's Board (http://www.greenguysboard.com/board/index.php)
-   General Business Knowledge (http://www.greenguysboard.com/board/forumdisplay.php?f=10)
-   -   Damn people, href="members" is a FILE. href="/members/" is a directory (http://www.greenguysboard.com/board/showthread.php?t=18003)

raymor 2005-03-28 01:52 AM

Damn people, href="members" is a FILE. href="/members/" is a directory
 
Well I'm currently doing a search and replace
on the 3rd site today, fixing thousands
of html pages where the webmaster didn't
know how to come up with a correct URL.
So in case anyone reading this doesn't know,
you'll know now. A link like this tries to find
a FILE called "members":
a href="members"
If you want the index page of a directory called "members/" you need the traling slash:
a href="members/"

Many servers are configured to catch this mistake
and redirect the user back to members/ instead.
In the best case, that means that it generates twice as many hits every time someone loads that page. First they ask for members, then the
server tells them to head over to http://yousite.com/members/
instead, then the browser sends another
request for members/.
In the worst case, it can fuck up a lot of shit.
For example that redirect won't work properly
with most of your anti-hotlinking code
or AVS site .htaccess.
So if you didn't know before, now you know if
you're linking to a directory (to get it's index page)
you must end the URL with a slash (/).

Chop Smith 2005-03-28 02:29 AM

Some of your clients might appreciate you doing a script to solve the problem discussed in this thread http://www.greenguysboard.com/board/...ad.php?t=18000

raymor 2005-03-28 03:08 AM

Quote:

Originally Posted by Chop Smith
Some of your clients might appreciate you doing a script to solve the problem discussed in this thread http://www.greenguysboard.com/board/...ad.php?t=18000

Thanks for reminding me of that.
I sure wish I could remember what I did on that
for someone else. It took a while but I eventually
developed something that worked quite well.
I do have an idea that should work pretty well, though.
Did you say you have some free galleries to try it out on?

Chop Smith 2005-03-28 03:31 AM

About 270. Let me know what you need

Barron 2005-03-28 02:33 PM

http://httpd.apache.org/docs/misc/rewriteguide.html


Trailing Slash Problem
Description:
Every webmaster can sing a song about the problem of the trailing slash on URLs referencing directories. If they are missing, the server dumps an error, because if you say /~quux/foo instead of /~quux/foo/ then the server searches for a file named foo. And because this file is a directory it complains. Actually is tries to fix it themself in most of the cases, but sometimes this mechanism need to be emulated by you. For instance after you have done a lot of complicated URL rewritings to CGI scripts etc.
Solution:
The solution to this subtle problem is to let the server add the trailing slash automatically. To do this correctly we have to use an external redirect, so the browser correctly requests subsequent images etc. If we only did a internal rewrite, this would only work for the directory page, but would go wrong when any images are included into this page with relative URLs, because the browser would request an in-lined object. For instance, a request for image.gif in /~quux/foo/index.html would become /~quux/image.gif without the external redirect!
So, to do this trick we write:

RewriteEngine on
RewriteBase /~quux/
RewriteRule ^foo$ foo/ [R]


The crazy and lazy can even do the following in the top-level .htaccess file of their homedir. But notice that this creates some processing overhead.

RewriteEngine on
RewriteBase /~quux/
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+[^/])$ $1/ [R]


-

Cleo 2005-03-28 02:38 PM

Leaving off the trailing slash is just one of the problems that I see.

I've seen sites that use file paths and names like "members/last year 1998/friend's of Foo/Babe's big blue outfit that she got for Christmas.jpg"

raymor 2005-03-28 03:31 PM

Note that the "solution" Barron posted truly is as it says
for "the crazy and lazy". The sane avoid making linsk like that
in the first place. :)

Barron 2005-03-28 03:34 PM

Quote:

Originally Posted by raymor
Note that the "solution" Barron posted truly is as it says
for "the crazy and lazy". The sane avoid making linsk like that
in the first place. :)


yep! |cheers|


-

ecchi 2005-03-29 05:45 PM

RE:"The sane avoid making linsk like that
in the first place." Yeah, but where do you go to get clients with this level of intelligence. Most of mine are so thick I am surprised that they don't die from forgetting to breathe.


All times are GMT -4. The time now is 12:23 AM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc