Im creating a new site, and Let me store my rewrite rules inside a database, rather than in the actual .htaccess files.
I've another site that utilizes Opensef (http://sourceforge.net/projects/opensef/) having a Joomla! installation that's carrying this out, but i am not even 100% how it operates beneath the hood.
How do i store these rules inside a database, query on their behalf on request and rediret towards the clean URL if found? It is possible to better method of doing this rather than loading up b .htaccess file (there might be thousands of records)?
You will get mod_rewrite to develop a map from exterior source for example performing a PHP or Python file which could obtain the data in the database and make up a mod_rewrite map.
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html (See right at the end)
RewriteMap quux-map prg:/path/to/map.quux.pl
Best Of Luck
Presuming each one of these pages are ultimately in Joomla, I believe using .htaccess or mod_rewrite is really a mistake.
I believe you are much best learning how Openserf works. I'd imagine it features a little bit of code that runs in early stages for each request that queries the database and issues a Redirect through PHP if there is a hit. An additional benefit of this method is it should be also easy to have Joomla rewrite links on its pages to suggest towards the clean version to begin with, saving the consumer an needless redirect
Incidentally, this is the way the Pathauto module in Drupal will it, and that i use that constantly on some pretty high volume sites with lots of 1000's of pages.
I believe that a great way to make use of rules saved inside a database is:
- Keep rules inside your database using your admin panel of the site.
- Then after upgrading database, produce a new .htaccess while using rules in DB making use of your server-side language solution.
- Replace old .htaccess with brand new one.
This eliminates the server load. It's much like Aiden Bell solution.
Grab the UrlRewriteFilter, butchers it to utilize a DB, and employ that in Tomcat rather than Apache.
Tomcat is really a fine web server and may do a lot of things Apache can perform (like FastCGI for PHP), and writing that for this is trivial in comparison to writing may be for Apache.
That which you most likely want is really a single rewrite rule to deal with every unknown request that is available in after which pass that to some small script which will handle the searches &lifier generate redirects. You can even skip the rewrite rule completely and employ the Apache ErrorDocument directive to pass through unknown Web addresses in to the script.
You have been pretty slim around the particulars of the items this 'new site' is but, you might like to consider building your Front Controller for that application &lifier getting it take proper care of all of the incoming Web addresses. Many (most?) web application frameworks take this method.