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.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Feb 2009
    Location
    Texas
    Posts
    56
    Thanks
    6
    Thanked 3 Times in 3 Posts

    Replace ?id=11 with title-of-video.html or /title-of-video/

    I have seen website written in php, wordpress is a good example, and they don't have ?id=11, instead they have an html file, or a folder.
    I am a beginner at PHP, I have only written one script. I am about to write another script where people will be adding content such as videos from youtube. How can do I get /title-of-video.html instead of /video.php?id=11 (?)

    Thanks,
    Camron
    Last edited by Camron467; 05-03-2009 at 04:53 AM.
    Free PSD to XHTML/CSS conversion - Dimby.net
    Which doctype should I use?

  • #2
    Regular Coder Iszak's Avatar
    Join Date
    Jun 2007
    Location
    Perth, Western Australia
    Posts
    332
    Thanks
    2
    Thanked 58 Times in 57 Posts
    Well what you're looking for is mod_rewrite, often these 'clean urls' have an id at the end or start of it so it's not exactly "/title-of-video.html" it's more in the form of "/title-of-video-0142.html" and the "title-of-video" can be anything, it's the id at the end that matters.

    Otherwise If you have seen it like you say, well then I'd expect that it searches the database for videos with that title but of course then you may have conflicts with the titles and hence why the most use id's in the url.

    A quick google search can find you information about mod_rewrite, the trick part would be using regular expressions to write the condition again another search.

    Regards

  • Users who have thanked Iszak for this post:

    Camron467 (05-03-2009)

  • #3
    New Coder
    Join Date
    Feb 2009
    Location
    Texas
    Posts
    56
    Thanks
    6
    Thanked 3 Times in 3 Posts
    Thanks,
    Free PSD to XHTML/CSS conversion - Dimby.net
    Which doctype should I use?

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,851
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Some CMSs like Wordpress use the title itself as the url, and there is an option to edit this entire url for our needs. In wordpress, they keeps an indexed varchar field named post_name to store the post title and then look up this table for serving the content.
    Last edited by abduraooft; 05-04-2009 at 08:08 AM.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

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