I’ve read through many articles discussing “User Friendly URLs” and I have come to the conclusion that Apache module mod_rewrite and the use of an external prg (program) using preferably PHP but if necessary Perl, is the answer. If there is a better answer please let me know. As for now I can’t seem to figure out how to get my “User Friendly URLs” method to work using Apache mod_rewrite.
What I want to achieve is to create virtual paths such as www.domain.com/products/ or www.domain.com/products/erv/ with trailing slashes that is passed into mod_rewrite to process this virtual path. Which breaks up the path into separate values (i.e. “products”, “erv”). Then queries the database for the topic id to determine if “erv” and/or “products” exists. If it does exist the topic id would be returned to the page to be processed other wise a 404 error should occur to the client. I don’t want to have to input direct references to all the paths into Apache’s httpd.conf or .htaccess as I have 11 topics with 70+ sub-topics to deal with. Going to a database is the best option I believe. In theory this should work however I’ve tried my own mod_rewrite RewriteRules and RewriteMap with no success of a value being returned. I’ve even tried examples that demonstration a similar method but no success. If anyone has an idea how to achieve this or can direct me into the right direction please let me know.
PHP code example to break up the path into separate values.
list($value1, $value2, $value3) = explode(“/”, $_SERVER['SCRIPT_URL']);
httpd.conf mod_rewrite in VirtualHost directive.
RewriteMap content prg:/var/www/htdocs/venmar/getTopicId.php
RewriteRule ^(.*)/(.*)/$ /index.php?nTopicID=${content:$1|0}