rahulephp Posted May 9, 2010 Share Posted May 9, 2010 Hi, I need to send product id with URL something like this: http://www.example.com/product.php?id=292&name=sony-digital-camera But this URL is not good enough for seo. Can anyone please let me know how to pass the ids and name (without "product.php") so that I will extract the id later http://www.example.com/sony-digital-camera-292.php All the operation takes place at "product.php" so I can't ignore it. But I don't want "product.php" page to be shown in URL. After rendering "product.php" page with respective product id, I'll get all of the parameters like name, price, description etc. Then now the URL of page would have to be (like this) http://www.example.com/sony-digital-camera-292.php (without "product.php") Thank you in anticipation Quote Link to comment https://forums.phpfreaks.com/topic/201178-how-to-make-seo-friendly-url-structure-using-php/ Share on other sites More sharing options...
Mchl Posted May 9, 2010 Share Posted May 9, 2010 This is done with Apache's mod_rewrite, not in PHP. Moving to appropriate section. Quote Link to comment https://forums.phpfreaks.com/topic/201178-how-to-make-seo-friendly-url-structure-using-php/#findComment-1055488 Share on other sites More sharing options...
cags Posted May 9, 2010 Share Posted May 9, 2010 The rewrite rule would be something like this... RewriteRule ^([a-zA-Z0-9-]+)-([0-9]+)\.php$ /product.php?id=$2&name=$1 Quote Link to comment https://forums.phpfreaks.com/topic/201178-how-to-make-seo-friendly-url-structure-using-php/#findComment-1055495 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.