Dok
08-20-2008, 05:22 AM
Hi all
I would like to map human readable URLs to the PHP generated URLs on my page.
For instance I would like users to be able to type http://www.mysite.com/a-brand-new-article.php and map the URL to something like http://www.mysite.com/art.php?aid=1
I currently do this by having a custom 404 script set up in apache. All the human readable requests generate a 404 and the script will query the DB and map the article name to the article ID. Then the script will send a header response and another page will then retrieve the content using the article ID.
This however imposes some overhead (2 request for every page view) as well as filling up the Apache error log with a huge amount of 404 entries.
1: How do I avoid that the user will see http://www.mysite.com/art.php?aid=1 in the address bar. I would of course like the http://www.mysite.com/a-brand-new-article.php URL to stay.
2: Can I use mod rewrite to do this? (how would you access the DB?)
3: Maybe I need another approach to the solution?
Any help is appreciated.
I would like to map human readable URLs to the PHP generated URLs on my page.
For instance I would like users to be able to type http://www.mysite.com/a-brand-new-article.php and map the URL to something like http://www.mysite.com/art.php?aid=1
I currently do this by having a custom 404 script set up in apache. All the human readable requests generate a 404 and the script will query the DB and map the article name to the article ID. Then the script will send a header response and another page will then retrieve the content using the article ID.
This however imposes some overhead (2 request for every page view) as well as filling up the Apache error log with a huge amount of 404 entries.
1: How do I avoid that the user will see http://www.mysite.com/art.php?aid=1 in the address bar. I would of course like the http://www.mysite.com/a-brand-new-article.php URL to stay.
2: Can I use mod rewrite to do this? (how would you access the DB?)
3: Maybe I need another approach to the solution?
Any help is appreciated.