Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.