Apache RewriteMap example

Today I needed to rewrite a list of about 1000 URL’s to a new location. Our product database was cleaned and new URL’s were created… Using RewriteMap from Apache’s Mod_rewrite comes in handy here.

In my case I needed to rewrite URL’s like this:




Where in my URL’s I had a 1000 different ‘poducts1234’ to rewrite to a new URL.


Here’s the HOWTO:

Create a textfile on your server with 2 columns. Something that would look like this:

And save it to a folder you wish, eg

from this file,  create a rewrite database,  more info: httxt2dbm

Once done,  open your vhosts config and add the following configuration:

A bit of clarification:

The line with content:

creates a condition that if the rewritemap contains the URI and the value is not “” (so an empty string) then it should perform the RewriteRule.

The rewrite rule itself is pretty obvious. It’ll rewrite the URL’s for which the rewritemap is found to the new product URL, and also keep the trailing parameters.

phpRedmin with apache, php5-fpm and mod_proxy_fcgi

With apache 2.4 and PHP5-FPM, the way to go is using mod_proxy_fcgi.

Since configuration of a normal proxy vhost  configuration is out of the scope of this article, I will not explain how to do this. There are lots of resources out there to find on how to impelement this. If i find the time to make an article on this, i will do so… 😉

So, today we were trying to configure phpredmin (imo the best Redis manamement tool out there) to work with Apache 2.4 using mod_proxy_fcgi to connect to PHP5-FPM.

We were having some issues with the configuration…The homepage was accessible, but all subpages were not proxied they they should. Pretty weird, as phpmemcachedadmin, phpmyadmin,… work without any special configuration on the apache side.

Hours of research led to the following fix: We created an extra vhost, and made some specific proxy rules in it:


Credits to Carl V 😉