Reputation: 117
i was running into a problem while creating a simple database and i hope you can provide me with some help ;).
The problem :
I need to create a database which contains offers (for example for hotels, holidays etc) thats no problem at all. What we want to do is to make each entry customizable with a single url that can be chosen by the author itself. For example we've got an overview page (overview.php) where all the offers are listed. Now i want to click on the first offer "Mallorca" for example which inherits the id 50. The dynamic URL would be something like "detail.php?id=50 for example, but i want to rewrite them from a individual field in my database that the author specified while creating the entry which looks as following :
Offer Name
Offer Date
Offer Price
URL (which can be anything, also blabla.htm)
The URL field should then be used to create a custom individual url for each offer - for example detail.php?id=50 would become mydomain.com/offers/mallorca.htm
I know that mod_rewrite can be consulted but i haven't figured out how to combine it to use fields from my database.
Any advice?
Upvotes: 0
Views: 355
Reputation: 16055
Just ideas for You to think of or bounce off:
mydomain.com/offers/50/
- it still looks better while the implementation tooks less timeRewriteRule ^/offers/(.*)$ detail.php?url=$1 [L, QSA]
RewriteRule ^/offers/(.*)/$ detail.php?id=$1 [L, QSA]
If You'd go with the first option (the one You desired), You would also have to look up the offer by the URL part provided, in the second option You look up by the ID.
Hope this helps.
Upvotes: 1
Reputation: 2759
You could rewrite as follows:
RewriteRule ^/offers/(*.)$ detail.php?url=$1
You then have to find your offer in the detail.php
file by it's url and the specified url GET parameter
Upvotes: 1