mcc_22ri Posted May 19, 2012 Share Posted May 19, 2012 Hi Everyone, I have a question regarding rewriting URLS in php while using data from your MySql database. Let's say for example I want to use certain keyword(s) from my database in my meta tags and URLS how would I go about doing that writing that in .htaccess? Would I have to create variables for certain keywords in my MySql database? For example, $product, $location etc .... and then place the above variables in my meta tags and URLS? and then reconfigure my .htaccess? Thanks for everyones help! Link to comment https://forums.phpfreaks.com/topic/262778-rewriting-urls-in-htaccess/ Share on other sites More sharing options...
wigwambam Posted May 19, 2012 Share Posted May 19, 2012 Here is a simple solution that I used once... .htaccess file: RewriteEngine On RewriteRule ^product/([0-9]+)/([^/]+)$ /product.php?id=$1&d=$2 [NC,L] Your URLs would be along the lines of:- http://www.yoursite.com/product/123/PRODUCT-NAME-HERE http://www.yoursite.com/product/74/PRODUCT2_DESCRIPTION_HERE Then, in product.php simply get the value of id. $id=$_GET['id'] Link to comment https://forums.phpfreaks.com/topic/262778-rewriting-urls-in-htaccess/#findComment-1346853 Share on other sites More sharing options...
cpd Posted May 19, 2012 Share Posted May 19, 2012 How you setup your mod rewrite is very dependant on how you want to structure your URIs. The example above shows a typical example but that may not be what you want. Link to comment https://forums.phpfreaks.com/topic/262778-rewriting-urls-in-htaccess/#findComment-1346863 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.