ivytony Posted October 30, 2008 Share Posted October 30, 2008 say there's a url http://www.domainA.com/readnews.php?id=109, the title for this piece of news is: I love SEO I would like to convert this url to something like http://www.domainA.com/109/I-love-SEO.html I wonder how to do this conversion using PHP. And how to pass the id (109 in this case) to readnews.php file? thanks Link to comment https://forums.phpfreaks.com/topic/130687-how-to-rewrite-url-to-seo-url/ Share on other sites More sharing options...
dezkit Posted October 30, 2008 Share Posted October 30, 2008 Your current URL is http://www.domaina.com/readnews.php?id=109&title=I-Love-SEO which you would like to see as http://www.domaina.com/109/I-Love-Seo Solution - Put the below lines in your .htaccess file RewriteEngine on RewriteRule ^([^/\.]+)/([^/\.]+).html$ /readnews.php?id=$1&title=$2 [L] Link to comment https://forums.phpfreaks.com/topic/130687-how-to-rewrite-url-to-seo-url/#findComment-678193 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.