Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other Extensionless URLs

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #27209
    mat
    Member

    Hi lovers of CSS-Tricks and Chris!

    I noticed this article based on what i can only assume removes the https://css-tricks.com/random".html"
    from the extension of the url.
    https://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

    #68180
    AshtonSanders
    Participant

    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,

    #68255
    mat
    Member

    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

    #68259
    AshtonSanders
    Participant

    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).

    #68270
    mat
    Member

    Cheers!

    Gunna have a play with it this weekend!

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Other’ is closed to new topics and replies.