Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,096
    Thanks
    26
    Thanked 0 Times in 0 Posts

    Directories and Pages and Slashes

    Is it correct that in the URL, a directory should end with a slash, and a webpage does not require one?

    For example...
    Code:
    www.debbie.com/legal/tax-law/  (Where Section = "Legal" and Subsection = "Tax Law")
    
    www.debbie.com/legal/tax-law/be-sure-to-charge-sales-tax  (Where Article= "Be Sure to Charge Sales-Tax")
    Sincerely,


    Debbie

  • #2
    Regular Coder
    Join Date
    Sep 2011
    Posts
    419
    Thanks
    18
    Thanked 26 Times in 26 Posts
    Short answer to them: No (both)


    Long answer:
    It depends on how the site is setup.
    For instance, some PHP engines (codeigniter for example) give meanings to each part. For instance example.com/news/article/2 could call a php class named "news", call the function "article" in that class (if it exists) and pass 2 to the function as a parameter. This is a lot easier and more dynamic than creating a directory "news" and then a sub-directory for "articles" in that, finishing off with a file for every article containing the data. Another way would be having the first argument ("news" in this case) include a file, which could load a template for articles and pass data to it for article 2.

    There's many ways you could handle the data and there are many possibilities, some are clean and both user and developer friendly, while others not so much.

    Overall, in a basic setup, you don't NEED the trailing slash for a directory, but if a file with that name exists, then it will take over, so it's better to use the trailing slash (although the chances of you having the file without an extension or the path with a period are slim, it's still possible).

    The site may redirect you and add the trailing slash on its own, I'm not too sure on that though.


  •  

    Posting Permissions

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