Mobile app version of vmapp.org
Login or Join
Murphy175

: Confirm if trailing slash is acceptable for a file, rather than a directory I have been reading on here and Google results for a few hours now including this question and the links therein

@Murphy175

Posted in: #Filenames #Url #Wordpress

I have been reading on here and Google results for a few hours now including this question and the links therein and many others. Including a URI building styleguide from the w3c and others.

I have settled on a format, I understand about apache, redirects, file extensions, and SEO. I am pretty sure (and it seems to be confirmed in the link to the Google Webmasters in the first question) that I understand but it just seems wrong...

example.com/directory/specific-page/ is OK for a file, right? (with trailing slash "/")

It doesn't necessarily mean that it is pointing to the index or default file in the /specific-page/ folder, right?

It is significant mainly because while I am using blogging software for my blog, I am hand-coding (to retain more control) the rest of the site. It is entirely plausible to me that WordPress would, rather than creating pages/files would actually create directories with index/default pages in them.

Up until now, I always thought that the trailing slash pointed to a directory's index page but that appears not to always be the case, is this correct?

Sorry, I feel like this topic has been well-discussed, but that is part of what is causing me problems.

I should note, I was leaning towards omitting the trailing slash from all pages, CMS generated or not, until I found this article from 2008 about the lack of a slash causing problems with Pingbacks in WordPress.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Murphy175

2 Comments

Sorted by latest first Latest Oldest Best

 

@Cofer257

The key point to understand here is that a URL is an abstract concept. In fact, they should technically be referred to as a URI (Uniform Resource Indicator, rather than Uniform Resource Locator).

In short, when a browser or user-agent makes a request to a URI, the server can return any content, with any headers.


mysite.com/directory/specific-page/ is OK for a file, right? (with trailing slash "/")


If you mean a binary file like an image, document or zip file, it should be avoided. As described above it's technically possible to serve files this way, but it could be confusing for users. Use an actual file name if possible.

If you mean a web page (HTML file), yes it is fine.


It doesn't necessarily mean that it is pointing to the index or default file in the /specific-page/ folder, right?


Again, you can make the server return whatever you like. It just happens that returning an index.html is the default behaviour on most servers.


Up until now, I always thought that the trailing slash pointed to a directory's index page but that appears not to always be the case, is this correct?


Yes. Apache will usually look for a folder in the specified location but there does not have to be one there if you configure something different via htaccess. And the "index page" could be any file.

10% popularity Vote Up Vote Down


 

@Rivera981

No, a trailing slash is not acceptable for files.



Unless...

You're going to need to set up canonical names on Apache.

Now, what you're talking about is simply a sort of redirect. A canonical name is simply an alias of another name. So, if you want to reference a file, it would be mysite.com/directory/specific-page/ is an alias to mysite.com/directory/pages/specific-page.php.

Files are always referenced with an extension. The reason for this is because of MIME types, so the browser knows what to do with the file that is delivered from the server.

It sounds like you've been in learning mode for a while now, and I don't want to information overload you, however you might benefit from learning how the client/server relationship works. This will help you visualize exactly what is happening when someone requests your site (thus making all of the other stuff simpler).

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme