Results 1 to 3 of 3

Thread: probably a simple question

  1. #1
    Join Date
    Oct 2009

    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
    This is typically done via the web server, such as by using mod_rewrite in a .htaccess file on an Apache web server.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  3. #3
    Join Date
    Jan 2006
    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