starboy Posted September 2, 2011 Share Posted September 2, 2011 I want to achieve a link like so: events/title-of-event But not quiet sure how I do that without passing it the id in the mod rewrite.. (ie: events/20/title-of-event) anyone ever run into this problem? Link to comment https://forums.phpfreaks.com/topic/246243-mod_rewrite-with-no-id-title-in-url/ Share on other sites More sharing options...
trq Posted September 2, 2011 Share Posted September 2, 2011 You need to change your database queries to search by name instead of id. Link to comment https://forums.phpfreaks.com/topic/246243-mod_rewrite-with-no-id-title-in-url/#findComment-1264605 Share on other sites More sharing options...
pal_20007 Posted September 7, 2011 Share Posted September 7, 2011 or just do a switch() php function switch for var %{query_uri) case "cars/"; $id =1 break; case "computers/"; $id = 2; break; then select sql Link to comment https://forums.phpfreaks.com/topic/246243-mod_rewrite-with-no-id-title-in-url/#findComment-1266340 Share on other sites More sharing options...
trq Posted September 7, 2011 Share Posted September 7, 2011 That would get pretty tedious pretty quickly. Link to comment https://forums.phpfreaks.com/topic/246243-mod_rewrite-with-no-id-title-in-url/#findComment-1266346 Share on other sites More sharing options...
cags Posted September 7, 2011 Share Posted September 7, 2011 You could also use a RewriteMap, and add the routes to the map when you create new categories. As a rule though, I'd agree with thorpe and say just change the db query to search by slug rather than id. Link to comment https://forums.phpfreaks.com/topic/246243-mod_rewrite-with-no-id-title-in-url/#findComment-1266388 Share on other sites More sharing options...
Boxerman Posted October 23, 2011 Share Posted October 23, 2011 Hi, Sorry to hijack this thread but as I found it I might aswell keep this alive rather than make a new thread. My question is like the above. I'm current using news.php?id=1 How do I get it to display: News/titlehere My php grabs the I'd and displays it for that, what do I enter in .htaccess to get what I desire? Link to comment https://forums.phpfreaks.com/topic/246243-mod_rewrite-with-no-id-title-in-url/#findComment-1281467 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.