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?
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
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]
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)