+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Extentionless URLs

  1. #1
    garrensilverwing's Avatar
    garrensilverwing is offline x10 Sophmore garrensilverwing is an unknown quantity at this point
    Join Date
    Nov 2008
    Posts
    148

    Extentionless URLs

    I searched the forums and could not find any tutorials or information on extentionless URLs if someone can please do a tutorial on it I would be very grateful or link a tutorial (that includes cPanel) that would be just as appreciated.

  2. #2
    tittat's Avatar
    tittat is offline x10 Spammer tittat is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Kerala,India
    Posts
    2,479

    Re: Extentionless URLs

    Tutorial section is not for asking question/help.No problem, i have moved this thread to programing help
    PLAY ONLINE GAMES
    WWW.TMONDO.COM PlayFar Flash Games
    Former X10 Forum Senior Moderator(Retired)


  3. #3
    garrettroyce's Avatar
    garrettroyce is offline Generally Helpful Member garrettroyce is a glorious beacon of lightgarrettroyce is a glorious beacon of light
    Join Date
    Apr 2008
    Location
    IL, USA
    Posts
    3,746

    Re: Extentionless URLs

    This is achieved through .htaccess and mod_rewrite.

    http://en.wikipedia.org/wiki/Mod_rewrite (mainly the links at the bottom)

    I think this is right:

    RewriteEngine on
    RewriteRule ^/([a-zA-Z0-9_-]+$ /$1.php

    This means, take all characters a to z A to Z and '-' and '_' between the first '/' (after http://www.yoursite.com) and the end of the url and rewrite it as those same characters with .php at the end.

    Don't give up, mod_rewrite is really really tricky
    Last edited by garrettroyce; 04-30-2009 at 10:24 PM.
    gjr.gr - coming soon: secrets of OCD coding from a self taught tinkerer

  4. #4
    garrensilverwing's Avatar
    garrensilverwing is offline x10 Sophmore garrensilverwing is an unknown quantity at this point
    Join Date
    Nov 2008
    Posts
    148

    Re: Extentionless URLs

    sorry, titat, i thought i could ask for a tutorial guess not :D, garrettroyce, thanks so much you're so helpful, i would give you more reputation but i have to spread it around a bit lol

    ok i found the htaccess file but i dont know how to edit it to insert that code is there a way to add that through cpanel? or some php script?
    Last edited by garrensilverwing; 05-01-2009 at 12:07 AM.

  5. #5
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Extentionless URLs

    Content negotiation is designed to do exactly what you want. Add:
    Code:
    Options +MultiViews
    to your .htaccess (the "+" means merge the options rather than replace them; read about the Options directive for details).

  6. #6
    Teensweb is offline x10 Lieutenant Teensweb is an unknown quantity at this point
    Join Date
    May 2008
    Posts
    352

    Re: Extentionless URLs

    "ok i found the htaccess file but i dont know how to edit it to insert that code is there a way to add that through cpanel? or some php script?"

    Download it to your pc and use text editors like notepad or something...

    For extension less urls, can't you just create a directory and put an index.html in it?
    Then when you goto http://www.yoursite.com/nameofyourdirectory
    you'll get to see the contents of index.html
    Why do you like to have extension less urls?
    Last edited by Teensweb; 05-01-2009 at 05:31 AM.

  7. #7
    garrensilverwing's Avatar
    garrensilverwing is offline x10 Sophmore garrensilverwing is an unknown quantity at this point
    Join Date
    Nov 2008
    Posts
    148

    Re: Extentionless URLs

    Quote Originally Posted by misson View Post
    Content negotiation is designed to do exactly what you want. Add:
    Code:

    Code:
    Options +MultiViews
    to your .htaccess (the "+" means merge the options rather than replace them; read about the Options directive for details).
    ok but i dont know how to edit the .htaccess file

    Quote Originally Posted by Teensweb View Post
    "ok i found the htaccess file but i dont know how to edit it to insert that code is there a way to add that through cpanel? or some php script?"

    Download it to your pc and use text editors like notepad or something...

    For extension less urls, can't you just create a directory and put an index.html in it?
    Then when you goto http://www.yoursite.com/nameofyourdirectory
    you'll get to see the contents of index.html
    Why do you like to have extension less urls?
    i tried that but no program that i have displays it so i can read it too many special characters or something
    Last edited by garrensilverwing; 05-01-2009 at 10:44 AM.

  8. #8
    garrettroyce's Avatar
    garrettroyce is offline Generally Helpful Member garrettroyce is a glorious beacon of lightgarrettroyce is a glorious beacon of light
    Join Date
    Apr 2008
    Location
    IL, USA
    Posts
    3,746

    Re: Extentionless URLs

    cPanel editor should work as well. Sometimes there's a problem with the differences in the way that *nix and Windows encode files, especially newlines.

    @mission I've never heard of using this before, thanks for the tip

    I prefer mod_rewrite simply because it has many other functionalities and learning regex is never bad :P

    For example you can make index.php?view=home&userid=3423 look like home/user3423
    Last edited by garrettroyce; 05-01-2009 at 01:28 PM.
    gjr.gr - coming soon: secrets of OCD coding from a self taught tinkerer

  9. #9
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Extentionless URLs

    Quote Originally Posted by garrettroyce View Post
    I prefer mod_rewrite simply because it has many other functionalities and learning regex is never bad :P
    Each does what it was designed to do fairly well. mod_rewrite and content negotiation have some overlap of function, but each for a different purpose. When it comes to type-via-file-extension agnosticism (which is the Right Thing to Do© in URIs), only content negotiation cuts the mustard. There's no longer a need to specify in a URI whether each page is stored as static HTML, a script or something else entirely, which is not easy to do with mod_rewrite. You can change the file type of a resource (page, image &c) without having to make any other changes. It also obviates the need for "choose a language" links in many cases.

    If you want your URI and filesystem hierarchies to be different from each other, however, only mod_rewrite will do.

  10. #10
    garrettroyce's Avatar
    garrettroyce is offline Generally Helpful Member garrettroyce is a glorious beacon of lightgarrettroyce is a glorious beacon of light
    Join Date
    Apr 2008
    Location
    IL, USA
    Posts
    3,746

    Re: Extentionless URLs

    Yes, but where content negotiation lacks is in query strings, which would be the next logical step in development of a user friendly URI. Even if your user is savvy enough to realize your site is using PHP or ASP.NET or any other technology, they probably won't remember site?this=123423&that=324&next=4212314 and unless you want to make one file for every single page you will ever have, mod_rewrite is the only tool to properly accomplish this. And why set up your site one way, knowing full well that you will probably have to change it later?
    gjr.gr - coming soon: secrets of OCD coding from a self taught tinkerer

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. image urls in sql
    By maxyes in forum Programming Help
    Replies: 1
    Last Post: 08-28-2008, 01:16 PM
  2. MediaWiki short urls
    By cowctcat in forum Free Hosting
    Replies: 2
    Last Post: 02-23-2008, 11:39 AM
  3. Something killed my clean URLs
    By nsm_nikhil in forum Free Hosting
    Replies: 4
    Last Post: 02-09-2008, 07:50 AM
  4. Replies: 16
    Last Post: 04-10-2007, 11:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers