SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    SitePoint Addict Aarem's Avatar
    Join Date
    Aug 2008
    Posts
    245
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    URI's without a final /

    Hi all,

    Not sure if this is the place to ask, but anyhow, I know that if you have a directory with a file called index.html or index.php etc, you can reference that index page by just citing the directory: e.g. mysite.com/directory. But once the index file is opened, the URI reads mysite.com/directory/ (with the slash at the end).

    It seems something else is happening on some sites, where you can cite a page and the URI remains without the final /, for example on this page from A List Apart:
    http://www.alistapart.com/articles

    Does anyone know how this works? Is it a feature of Ruby on Rails (which this site uses)? Is the word 'articles' above referring to a page or a directory?

    I'd love it if anyone could shed some light on this, as I've been wondering about it for quite a while.

    Many thanks.
    Simple is beautiful.

  2. #2
    Design Your Site Team bronze trophy Erik J's Avatar
    Join Date
    May 2007
    Location
    Countryside, Sweden
    Posts
    3,407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A List Apart seems to use absolute paths in their documents, so they are not depending on the current directory.

    Other sites uses relative paths and need to solve the Trailing Slash Problem.

    Others sites again are concerned about the Doubled Content Issue regarding search engin rules.
    Happy ADD/ADHD with Asperger's

  3. #3
    SitePoint Addict Aarem's Avatar
    Join Date
    Aug 2008
    Posts
    245
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks erik.j. I don't fully understand those links, but I get the sense that a link like http://www.alistapart.com/articles is referencing a directory and not a file. I just wondered if there was a major technique going on here that I was unaware of, but it seems not.

    Again, thanks for answering.
    Simple is beautiful.

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,784
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Without the trailing slash it is most likely referencing a file rather than a directory sine if there is no trailing slash the browser looks for a file by that name and if it can't find it then adds the trailing slash to see if it can find a directory.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  5. #5
    SitePoint Wizard
    Join Date
    Apr 2002
    Posts
    2,301
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    this apache module will automatically add the trailing slash - DirectorySlash:
    http://httpd.apache.org/docs/2.0/mod...DirectorySlash
    so that's probably what a lot of servers which add a trailing slash are using because i think DirectorySlash being on is the default

  6. #6
    SitePoint Addict Aarem's Avatar
    Join Date
    Aug 2008
    Posts
    245
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    Without the trailing slash it is most likely referencing a file rather than a directory since if there is no trailing slash the browser looks for a file by that name...
    Ah, OK. Is it considered bad practice not to include a file type, like .html or .php? Is there any particular reason why this option would be chosen?
    Simple is beautiful.

  7. #7
    SitePoint Member
    Join Date
    Nov 2007
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There's definitive information on this at Yahoo performance under Avoid Redirects.

  8. #8
    SitePoint Member
    Join Date
    Nov 2007
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thats at Developer dot yahoo.
    Search under Yahoo

  9. #9
    SitePoint Addict Aarem's Avatar
    Join Date
    Aug 2008
    Posts
    245
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for that. I assume you mean this page:
    http://developer.yahoo.net/blog/arch...formanc_9.html

    As with most things on the web, it does not clearly outline what its subject really is, so I'm not sure if it answers my question or not. But still worth reading.
    Simple is beautiful.

  10. #10
    SitePoint Member
    Join Date
    Nov 2007
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes. That's a more detailed page. There's another web page which has all the rules on it.
    Is that page helpful?

  11. #11
    SitePoint Member
    Join Date
    Nov 2007
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Red face

    The trailing slash gives me an easy way to get people to contact me.


    But I am still considering using index dot htm after the slash explicitly though perhaps because my google analytics makes a distinction on different pages, search engines make a distinction, and also cause I accidentally used the full path in one or more of my internal links.

  12. #12
    SitePoint Member
    Join Date
    Nov 2007
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think basically the articles says if you do not use the trailing slash Apache usually fills it in for you.
    On my host if you have a file such as slash example dot htm
    and you put example or example "slash" as a URI then it will find example dot htm, unless there is a directory called "slash" example "slash"

    There's some other page on the web about the trailing slash. If I find it I will post it.

  13. #13
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Chances are it's an Apache Mod-Rewrite, that redirects requests from /articles to a file made for handling articles.

    For example on my server, if a request doesn't find a file associated with it, it will send the request to index.php?path={path} which programmatically finds out what to do with the page.

    For example, an url like:
    mysite.com/PHP/OOP/Introduction

    would be rerouted to:
    mysite.com/index.php?path=PHP/OOP/Introduction

    Where the PHP code then splits that path up, and outputs the appropriate content.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  14. #14
    SitePoint Addict Aarem's Avatar
    Join Date
    Aug 2008
    Posts
    245
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks both. I think I'm starting to get it now. I mainly wanted to know if there was some kind of simple, neat way to create these urls that I had not heard of. Seems like it's best generally to stick with the trailing slash and not try to get too fancy (at least for me, knowing nothing about Apache etc...)
    Simple is beautiful.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •