Question about trailing slash with URL

On some other forum I recently put link to my portfolio page and at the end of the URL I put trailing slash ( / ) like this

[B]http://www.domain.com/portfolio.html/[/B]

I did not realize that the above page does not exist on my site because my portfolio page does not have trailing slash.

[B]http://www.domain.com/portfolio.html[/B]

I just saw 20 NOT FOUND errors in google webmasters tools.

Isn’t there any way to redirect all URLs with / to without slash URLs?

actually, and this is perhaps gonna surprise you, but that trailing slash should actually be there whenever you are linking to a directory

if you send a request for http://example.com, the web server says “i ain’t got a file by that name” so your browser automatically slaps a trailing slash on it and makes a second request for http://example.com/ – this is a valid folder (the root folder), so you get the default page for that folder

if you ~do~ have folders in your web site, the same thing happens when you send a request for http://example.com/myfolder – the web server says “i ain’t got a file by that name” so your browser automatically slaps a trailing slash on it and makes a second request for http://example.com/myfolder/ – and once again, this is a valid folder, so you get the default page for that folder

does that make sense?

my understanding is that /'s in urls are used to simply separate directory names in the urls just like they are used to separate directories/folders in a path name to a file on your computer.

if a url ends with a / that is telling the server the last name in the url path is a folder and the server sends back the default page in that folder (usually something like index.php, index.htm, home.php or home.htm

http://www.decentbanners.com/portfolio.html/

is telling the server that portfolio.html is a folder when in reality it is not.

I think I noticed this issue very late. This site is running as it is for the past 2 years and never got issue, it has got PR4 and now if I do something to put / at the end it can affect my site ranking :frowning:

Also, I don’t know how to put / at the end. It is simple HTML site, no scripts running (except for order page).

Some CMSs by default don’t add a trailing slash at the end of the url, even though it appears to be a folder.

If you put a file into a folder and call the file index.html (or index.php etc—the important bit is “index”) then you can point to it by citing just the folder.

E.g.

If you put an index.html page inside a folder called /articles/ which is inside the root folder, you can point to that index page like this:

mysite.com/articles/

If you put an index.html page inside a folder called /articles/ which is inside the root folder, you can point to that index page like this:

mysite.com/articles/

IF DirectoryIndex is turned on. It is by default on my version of Apache, but I dunno about all other servers.

That would only work if you include a filename in every URL and don’t expect anyone to ever try to visit a URL without including the filename. And that ain’t going to happen. Because, as Rudy said, if someone hits on a URL without a filename, but just the domain name and maybe a folder name, the trailing / is automatically added. So if you remove it, that’s going to cause problems.

What I’m sure you could do is redirect any URLs that end .html/ to end .html - you might be better off asking about that on the Apache forum, because I’m none too sure about creating the regular expression to do that…