dynamically rewrite URLs
Posted: Fri Apr 01, 2011 8:23 am
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
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