Dropping .html from printed links

Discussion in 'Web Design and Development' started by irishgrizzly, Feb 18, 2010.

  1. irishgrizzly macrumors 65816

    irishgrizzly

    Joined:
    May 15, 2006
    #1
  2. astroot macrumors regular

    Joined:
    Nov 12, 2009
    #2
    Yes, just Google "extensionless url htaccess" and I'm sure you'll find the answer.
     
  3. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #3
    There are some solutions using .htaccess, but it's likely to have unintended effects that will screw things up.
     
  4. digitalField macrumors regular

    Joined:
    May 21, 2004
    Location:
    portland
    #4
    i might be wrong, but isn't every extensionless url done via htaccess at one level or another?

    so maybe your saying that a quick htaccess tweak thrown into the site might mess up some other things like directories or image files, but when used in frameworks htaccess files can work exactly as intended and clean up urls quite nicely.

    M
     
  5. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #5
    Apache-based hosts web sites would, but not all web sites use Apache web server. Some use others like MS's IIS. PHP can also be used as a solution, but it's not as clean as .htaccess.
     
  6. Bostonaholic macrumors 6502

    Bostonaholic

    Joined:
    Aug 21, 2009
    Location:
    Columbus, Ohio
    #6
    Like mentioned above, if your site is hosted using Apache, lookup something called mod_rewrite. In a nutshell, you .htaccess file would have something like this

    Code:
    RewriteEngine On
    RewriteRule ^mylink/?$ /mylink.html
     
  7. hobbbz macrumors 6502a

    hobbbz

    Joined:
    Mar 8, 2005
    #7
    If I were you I'd just create a folder and have an index.html file in that folder. This is the less hacky, common-sense way to do what you want.
     
  8. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #8
    It is also incredibly messy and hard to maintain. Plus most sites tend to use dynamic URLs which require the use of mod_rewrite to clean them anyway.
     
  9. lag1090 macrumors 6502

    Joined:
    Jan 28, 2007
    Location:
    NJ
    #9
    The absolute simplest way to do it without modifying .htacess is to just create a folder called "mylink" where you intend to have the page stored, then move "mylink.html" to the new folder, and finally rename "mylink.html" to "index.html"

    Edit:
    It's not quite as difficult to maintain if you have static pages. If you are dealing with dynamic content, it may become a pain, but it's really the only way (that I'm aware of, that is) that would achieve your desired result without modifying .htaccess or other server settings.
     

Share This Page