dynamically rewrite URLs

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Zander1983
Forum Newbie
Posts: 20
Joined: Mon Mar 21, 2011 2:26 pm

dynamically rewrite URLs

Post by Zander1983 »

Hi
Im setting up a website where people can start their own shops and the url is http://www.mydomain.com/shops/shop_name

Now i have a simple mod_rewrite rule which directs urls above to the shop_details.php page.

What i need to do is dynamically create new rules because when a shop adds a product, it will look like http://www.mydomain.com/shops/shop_name/product_name

In cases like this, is it correct to edit the .htaccess file on the fly using File Write and add a new rule to the file. Then when a user hits the url http://www.mydomain.com/shops/shop_name/product_name, the new rule will recognise the shop and product and redirect to product_details.php.

I think this method will work, Im just wondering is this the normal/correct way to go about solving a problem like this....
thanks in advance
User avatar
MindOverBody
Forum Commoner
Posts: 96
Joined: Fri Aug 06, 2010 9:01 pm
Location: Osijek, Croatia

Re: dynamically rewrite URLs

Post by MindOverBody »

Why dont you use one of frameworks? Zend have nice modular capabilities, and it is pretty simple to use.
Post Reply