Jump to content

Rewriting URLS in htaccess?


mcc_22ri

Recommended Posts

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

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']

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.