Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    New to the CF scene
    Join Date
    Apr 2008
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    How do websites that use no extensions work?

    For example, http://www.last.fm/users/. I never see any file extensions on that site... I don't even know if it's in php but how does it work? And how would I even figure out how it's programmed?

  • #2
    Regular Coder
    Join Date
    Mar 2008
    Posts
    118
    Thanks
    3
    Thanked 9 Times in 9 Posts
    What is happening there is that you are really on a page called "index.php" or something like that, because in their hosting account they have sent the automatic default page to be "index.php" or something similar.

    In other words, they can send you to a directory without a specific file, but the default file manager automatically allows their default page to be pointed to.

    Just like when you go to almost any domain, it typically wont be http://www.thesite.com/index.php ... rather, it will just be http://www.thesite.com/ without an extension.
    Last edited by peteyb383; 05-18-2008 at 10:16 PM.

  • #3
    LAMPE
    Guest
    They have modified their .htaccess and did a mod_rewrite

  • #4
    New to the CF scene
    Join Date
    Apr 2008
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Would mod_rewrite allow them to have something like http://www.last.fm/user/MJBoa? They obviously don't have a page called MJBoa.php or something and I assume there aren't thousands of directories with user names so how does it interpret that into someone's username?

  • #5
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    Likely, you'll find that www.last.fm/user/MJBoa isn't just a url. Probably, the url is www.last.fm/user and the 'MJBOa' is part of the path sent to the php file at /user telling it whose data to display, presumably, from a Db.

    bazz.

  • #6
    New to the CF scene
    Join Date
    Apr 2008
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I was thinking that there might be an index.php in user/ that responds to something like user/MJBoa but how does it know to load index.php and not the MJBoa directory? I'm trying to figure this out so I can implement something similar, thanks for the help.

  • #7
    Regular Coder dniwebdesign's Avatar
    Join Date
    Dec 2003
    Location
    Carrot River, Saskatchewan
    Posts
    838
    Thanks
    15
    Thanked 9 Times in 9 Posts
    You can use .htaccess to do just this. I have a website I am currently constructing something simlar for user profile pages where it is http://mywebsite.ca/username takes it to a user page.

    What the .htaccess does is takes it and shows a page which is really http://www.website.ca/profile.php?user=username but the site looks like I said above.

    In fact I asked a similar question here: Page that looks like directory...
    Dawson Irvine
    CEO - DNI Web Design
    http://www.dniwebdesign.com

  • #8
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    If you have access to the server, you don't need to make any htaccess changes.

    Simple set the server to show index.php by default. All my isp's, when on a shared platform had the server set up taht way. When I moved to my own dedicated server, that was the default setting and when I wanted to change from showing index.htm by default, to showing index.shtml, it took only one phone call.

    Maybe that would be your easiest way?

    bazz

  • #9
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts
    here you go i poped something together quickly for you..

    ok htaccess

    Code:
    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    
    RewriteRule ^([^/.]+)/?$ lastfm/users.php?page=profile&username=$1
    ok so as you can see the page = profile.. so profile.php in this case so it pulled up profile.php and username is the username you have typed into the url so www.last.fm/user/MJBoa well bring up MJBoa's profile

    of course there is more to it then that because you need to pull the information from the db for username but its really easy... hope that helps explain a little more

  • #10
    Regular Coder
    Join Date
    Sep 2006
    Location
    Vermont, USA
    Posts
    154
    Thanks
    0
    Thanked 6 Times in 6 Posts
    .htaccess is by far the cleanest way, but it does introduce a layer of abstraction. You can always set your sites 404 page to be index.php and then deal w/ the conditions there - thou i wouldnt recommend it for anything more than proof of concept.
    Active PHP/MySQL application developer available for immediate work.
    syosoft.com mavieo.com - Remote Web Site Administration Suite - Reseller Ready

  • #11
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,801
    Thanks
    160
    Thanked 2,216 Times in 2,203 Posts
    Blog Entries
    1
    syosoft, can we post data from a form to index.php, if we follow such an ErrorDocument rule?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #12
    Regular Coder
    Join Date
    Sep 2006
    Location
    Vermont, USA
    Posts
    154
    Thanks
    0
    Thanked 6 Times in 6 Posts
    Sure, apache would route every non existing page to 404 (index.php), post and all - again, i'm not really suggesting this method. If you have the ability to use .htaccess, dont let ModRewrite scare you - it is an extremely powerful tool.

    I'd rather see you use a design pattern similar to what i recently wrote up. See Simple Template System Tutorials
    Active PHP/MySQL application developer available for immediate work.
    syosoft.com mavieo.com - Remote Web Site Administration Suite - Reseller Ready

  • #13
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,801
    Thanks
    160
    Thanked 2,216 Times in 2,203 Posts
    Blog Entries
    1
    I had been using
    Code:
    ErrorDocument 404 /index.php
    and then use $_SERVER['REQUEST_URI'] to decide which pages are to be included in to index.php. (All my links are of the form /home, /about etc)

    But then I realised that external data is not getting passed to index.php. So, I've added
    Code:
    RewriteRule ^([^/\.]+)$ index.php [L]
    also in to my htaccess and found everything OK.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #14
    Regular Coder
    Join Date
    Sep 2006
    Location
    Vermont, USA
    Posts
    154
    Thanks
    0
    Thanked 6 Times in 6 Posts
    Ok - good to point out. I was apparently wrong about $_POST data coming along as a result of ErrorDocument.

    You might want to change that to [QSA,L] so the querystring comes along as well.
    Active PHP/MySQL application developer available for immediate work.
    syosoft.com mavieo.com - Remote Web Site Administration Suite - Reseller Ready

  • #15
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,801
    Thanks
    160
    Thanked 2,216 Times in 2,203 Posts
    Blog Entries
    1
    sysoft, but where to add that condition, in my above case?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •