Grow your CSS skills. Land your dream job.

Extensionless URLs

  • mat
    # December 15, 2009 at 9:46 am

    Hi lovers of CSS-Tricks and Chris!

    I noticed this article based on what i can only assume removes the http://www.css-tricks.com/random".html"
    from the extension of the url.
    http://css-tricks.com/snippets/javascri … avascript/

    However i wasn’t sure ? how would i implement this ?

    Is there a simple way using htaccess and/or Javascript to simple remove the extension from a url?

    I understand you can use the mod_rewrite expression but everytime i try it out i fail!

    Maybe chris you could write a very brief tutorial post ?

    Much lovex
    Mat

    # December 15, 2009 at 11:59 am

    Actually, that is done by WordPress.

    If you want to do it manually, you just need to create folders, and put the page in it as index.php.

    Ex:
    domain com/folder-name/index.php

    Then you can just accesse page by typing in:
    domain com/folder-name/

    Enjoy,

    mat
    # December 17, 2009 at 7:39 am

    Yea this method however means i end up with a massive amount of folders in the ftp lol.

    Chris needs to do beginners friendly htaccess tutorial :P

    # December 17, 2009 at 12:02 pm

    Haha. Yes, that is true.

    Another option is to use database driven content and create one file that will decipher which page the visitor wants. Here’s the htaccess that WordPress uses:

    Code:
    # BEGIN WordPress

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

    # END WordPress

    This rewrite checks (every time an address is typed into the browser) to see if a file or directory exists already, and if it doesn’t it loads the index.php file (which then figures out what page to display based on the URI).

    mat
    # December 18, 2009 at 6:18 am

    Cheers!

    Gunna have a play with it this weekend!

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".