www.webdeveloper.com
Results 1 to 3 of 3

Thread: probably a simple question

  1. #1
    Join Date
    Oct 2009
    Posts
    58

    probably a simple question

    instead of displaying my urls like www.mysite.com/?id=THE_ID
    how can i make it mysite.com/THE_ID and get the same data?

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,354
    This is typically done via the web server, such as by using mod_rewrite in a .htaccess file on an Apache web server.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Jan 2006
    Location
    MN
    Posts
    440
    The solution is to create links the way you want them to look, and then convert the link to an ID in .htaccess, and then grab the resulting variable in your code to display the page the way you want it.

    I cheated to do mine. URL looks like http://www.mysite.com/20110311275/my-article.html the tail end of the date string contains the ID number of the article. In this case 275, the name of the html portion becomes the title for the page by using ucwords(). .htaccess outputs two variables id and title.

    #RewriteRule ^([0-9]+)/([a-zA-Z0-9-]+)\.html$ /index.php?id=$1&title=$2 [L,nc]

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles