httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Josh Trutwin <>
Subject [users@httpd] RewriteMap questions
Date Wed, 30 May 2007 18:53:48 GMT
I have been asked to create rewrite rules for sites that use an old
page naming scheme to a new one.  The first attempt was to create
a .htaccess file that had a rewrite rule for every page, something

RewriteRule ^new_page_name.php$ /sitepages/pid123.php [L,QSA,NC]

Works ok for small sites, but some of them have thousands of pages
which translates to thousands of RewriteRules which of course bogs
down the apache server.

I was going to look at creating a rewritemap using a .db hash file -
my main concern is that we have some existing URL's that map to
actual files on the system.  My thought was to do something like this:

RewriteMap existing  prg:/path/to/file/
RewriteMap redirects dbm:/path/to/file/map.db

RewriteRule ^/(.*) ${existing:$1} [L,QSA]
RewriteRule ^/(.*) ${redirects:$1} [L,QSA]

My thought being that the first map is a program that tests if the
URL matches an actual file/dir in the doc root, returning NULL if it
doesn't.  If it matches then processing would stop and the first
RewriteRule would work.  But if it doesn't match, does the second
RewriteRule even get executed?  If not, do I then have to resort to a
single map that is a perl program that first checks if the URL maps
to a page and if not manually reads the map file?

Also, curious if anyone has a PhP example of a map program, I'm a
little more proficient in that - or even python...



The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message