httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Josh Trutwin <j...@trutwins.homeip.net>
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
like:

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/map.pl
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...

Thanks,

Josh

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message