How do I convert a PHP query string into a slash-based URL?
Basically have database driven pages with web addresses such as this:
http://www.companyname.com/dynamic_page.php?id=1 http://www.companyname.com/dynamic_page.php?id=2 http://www.companyname.com/dynamic_page.php?id=3 ... http://www.companyname.com/dynamic_page.php?id=4001 http://www.companyname.com/dynamic_page.php?id=4002 http://www.companyname.com/dynamic_page.php?id=4003
In which the id within the url can be used to obtain the correct content in the database, and also the user is able to add/remove/edit as numerous pages as s/he wants.
I learn how to by hand use mod_rewrite to own web addresses a better look e.g.
http://www.companyname.com/individual/1 http://www.companyname.com/individual/2 http://www.companyname.com/individual/3 ... http://www.companyname.com/commercial/4001 http://www.companyname.com/commercial/4002 http://www.companyname.com/commercial/4003
But exactly how would I actually do that dynamically? i.e. permit the user to specify area of the url, within this situation the consumer has selected either "individual" or "commercial", adding the id in the finish from the url, without me needing to edit the .htaccess file each and each time a person constitutes a new page, or edits/removes a webpage.
I believe that this may be enough:
RewriteRule http://www.companyname.com/(.*)/(\d+) http://www.companyname.com/dynamic_page.php?id=$2
It does not appear is before /4441, it'll always result in dynamic_page.php?id=4441...
Are you currently by hand adding a brand new line for each ID within the ht access file?
You can accomplish all this easily having a regular expression. Here is a publish that's a little old but is totally in accordance with your requirements: http://www.webmasterworld.com/forum92/4332.htm
Take a look at -> Clean Urls
You can test.
RewriteEngine On RewriteRule ^companyname.com/(.*)/(\d+)$ /$1.php?id=$2
RewriteRule http://www.companyname.com/(.*)/(\d+) http://www.companyname.com/index.php?firstvalue=$1&secondvalue=$2