Results 1 to 5 of 5

Thread: [RESOLVED] DIGG.COM's url formatting - how to.

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2007
    Posts
    4

    Resolved [RESOLVED] DIGG.COM's url formatting - how to.

    I am sorry for the slightly weird title to this thread, but I honestly have no way of explaining it without giving examples as I know not what this technique is called.

    Go to Digg and take a look at any random story's comments. After (mostly) cringing at the ridiculous comments and knowing that little extra about politics, notice the URL.

    It looks as if the page is index.php (or similar) in the folder "This_is_boring_us_to_death", but I am also sure I've seen some kind of technique that makes the end user unaware of what the file name for the page is, and what language was used to create that page...etc.



    Basically, do websites like digg.com literally create a new folder, name it the story title and then put the content in one page inside that, or is there another way of doing it so the URL looks like digg's? Even the name of this little feature would be good, so I can research it more.

    Once again, apologies for the crappy title and explanation If nobody understands it I'll try and re-write it.

  2. #2
    Hyperactive Member
    Join Date
    Dec 2006
    Location
    Ubuntu Haters Club
    Posts
    405

    Re: DIGG.COM's url formatting - how to.

    No, it's called Rewrite rules on the web server.

    Apache = mod_rewrite
    IIS = ISAPIRewrite
    Lighttpd = Built in

    You can rewrite URLs such as /politics/* to index.php?page=*, then handle it accordingly.

    For example you could have something like /hello-world/ redirect to hello-world.php.
    » Twitter: @rudi_visser : Website: www.rudiv.se «

    If Apple fixes security flaws, they are heralded as proactive. If Microsoft fixes a security flaw, they finally got around to fixing their buggy OS.

  3. #3
    Frenzied Member I_Love_My_Vans's Avatar
    Join Date
    Jan 2005
    Location
    In the PHP compiler
    Posts
    1,275

    Re: DIGG.COM's url formatting - how to.

    I dont like to say this, mainly because I think I do it wrong, but I have used a method like this.

    I have a URL, e.g. http://www.mysite.com/Never_guess_what,

    As this 'directory' doesnt exist it fires a 404 error, I then catch that error, query the URL and redirect to the page of choice.

    Of course on your server you have to be able to control your 404 (400, 403, 500 errors), but if you can do that send the error to a custom script, grap the URL using the $_SERVER variable and boom, sorted.

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: DIGG.COM's url formatting - how to.

    Quote Originally Posted by ILMV
    I dont like to say this, mainly because I think I do it wrong
    Yeah, you are doing it wrong. Your method will probably (depending on the web server) still send a 404 status code back to the client. Although this probably won't affect a human, it will mean that any automated tool — such as a search engine crawler — will think that no page exists at that address.

    The rewriting option is the correct method of achieving proper virtual URIs as this does not affect the status code.

    Example for Apache:
    Code:
    RewriteEngine On
    RewriteRule ^.*$ /home/www/index.php [L]
    That will pass all requests through to /home/www/index.php. You can then parse the variable $_SERVER['REQUEST_URI'] and serve the appropriate content.
    Last edited by penagate; May 29th, 2008 at 09:33 PM.

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2007
    Posts
    4

    Re: DIGG.COM's url formatting - how to.

    RudiVisser:
    Ah, apache. Thinking about it logically it would have to be that (unless you processed 404's, as I_Love_My_Vans said) lol. Oh well, this information is exactly what i need, thank you very much!

    I_Love_My_Vans:
    Even though i will be going with the mod_rewrite way, this is still a work-around i did not think of. Always nice to know

    penagate:
    Thanks for the examples and more detailed explanation!

Posting Permissions

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



Click Here to Expand Forum to Full Width