SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Enthusiast Marty Chambers's Avatar
    Join Date
    Oct 2009
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Making the ".html" not appear in the address box

    I'm pretty sure there's a way to take off .html extensions in the address box, so that

    http://www.sitepoint.com/forums/newthread.php

    becomes

    http://www.sitepoint.com/forums/newthread/

    (Well in that case it's php, but I'm interested in the .html)

    How is this done?

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,816
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    There are two ways to do it - the easiest way is to set up each page as index.html in its own folder where the folder name is what you want people to see for that page.

    The more difficult way is to update the .htaccess file (assuming you are using Apache) to parse all filenames without an extension as HTML (or the equivalent to this for other web servers). That could also have unforseen consequences regarding other files on your hosting.
    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="^$">

  3. #3
    SitePoint Enthusiast Marty Chambers's Avatar
    Join Date
    Oct 2009
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmmm doing it the first way would require editing the markup of every URL in the HTML wouldn't it?

  4. #4
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,198
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    It would require setting up new folders, creating new index pages and pasting the old page code into each new index page. So it's a bit messy. The pages also will have to re-establish themselves in search engines, and you'll need to redirect the old pages to the new pages to avoid a lot of 404/page not found errors.

    Obviously the ideal is to do this from the outset.

  5. #5
    SitePoint Enthusiast Marty Chambers's Avatar
    Join Date
    Oct 2009
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ralph.m View Post

    Obviously the ideal is to do this from the outset.
    Yes, I'm seeing that xD

    Do many people do this? Is it considered a cheap way out or acceptable among in-the-know designers?

  6. #6
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,198
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    As far as I know, it's considered good practice. I've even read about it in SitePoint books. I certainly do it myself. (Apparently, one slight advantage is that, if your extension--such as .php--is hidden from view, hackers have less idea of how to invade your site. How much that really helps I don't know ... if at all.)

    It certainly makes for neater urls, which is why I like it.

    PS

    A third option is to use a content management system, which often produces urls like mysite.com/folder. It depends of the CMS, though, and this is probably even less helpful for your current situation.

  7. #7
    SitePoint Enthusiast Marty Chambers's Avatar
    Join Date
    Oct 2009
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In order to make the CSS work in this scenario, one would have to make the URL something like

    "http://sitepoint.com/sitepoint.css"

    instead of just

    "file/sitepoint.css

    And all of the pictures would have to have a similar URL. Or is this the way it should be done anyway?

  8. #8
    SitePoint Enthusiast Marty Chambers's Avatar
    Join Date
    Oct 2009
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ralph.m View Post
    It would require setting up new folders, creating new index pages and pasting the old page code into each new index page..
    Why not just rename the old pages? That would be a lot simpler, and wouldn't affect search engines...

  9. #9
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,198
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by Marty Chambers View Post
    Why not just rename the old pages? That would be a lot simpler, and wouldn't affect search engines...
    Renaming page.html to index.html still means that the page is now not found at its old address. That's what I meant. There will be lots of links out there to page.html, and they will return an error if someone clicks on them. (I renamed some pages over two years ago and still find that people click links to them... somewhere or other. So I have to make sure there is redirection set up.)

    In order to make the CSS work in this scenario, one would have to make the URL something like

    "http://sitepoint.com/sitepoint.css"

    instead of just

    "file/sitepoint.css
    I don't understand what you are saying here.

  10. #10
    SitePoint Guru
    Join Date
    Nov 2008
    Posts
    622
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    if you have many pages then use cms like wordpress and joomla which comes with seo friendly urls or short urls.

    otherwise you can create .htaccess file and rewrite urls.

    vineet

  11. #11
    SitePoint Enthusiast Marty Chambers's Avatar
    Join Date
    Oct 2009
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ralph.m View Post

    I don't understand what you are saying here.
    Well for example an excerpt of the HTML markup for my homepage is

    <link href="martyn.css" rel="stylesheet" type="text/css"/>

    Putting index.html inside a folder will disable the index.html from being able to access the "martyn.css." So the <link> element URL would have to be changed to href="martynchamberlin.com/martyn.css"

    Does that make sense

  12. #12
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,816
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Since the entire idea behind what was originally asked is to change the filenames I can't understand why that is considered to be an issue. If you get rid of the .html by whatever method then you are changing the file names.
    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="^$">


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
  •