Good morning Apache list, I have a strange mod_rewrite problem, and I'm not sure how to solve it. I have a RewriteRule that works correctly on one apache daemon, but doesn't work when copied and pasted to the httpd.conf file of a second apache daemon.
To state this differently, on the second apache daemon, mod_rewrite is correctly matching the URL based on the regex, but it is not substituting the back-references into the target URL. The rule looks like this: RewriteRule /products/(.*)/(.*)\.html$ /perl/ detail.pl?url_name=$1&model_nbr=$2 On the first server this successfully matches this request: http://www.mydomain.com/products/whirlpool/1234567.html, and does an internal redirect to /perl/detail.pl?url_name=whirlpool&model_nbr=1234567 On the 2nd (malfunctioning) server, it doesn't work -- although mod_rewrite correctly matches the request to the rule, it doesn't substitute the values inside the parentheses to $1 and $2 in the output URL. Here's what gets written to the output of the RewriteLog on the 2nd server: 192.168.1.3 - - [26/Jan/2010:10:17:06 -0600] [ www.mydomain.com/sid#9094fec][rid#90a8b3c/initial<http://www.mydomain.com/sid#9094fec][rid%2390a8b3c/initial>] (2) init rewrite engine with requested uri /products/whirlpool/1234567.html 192.168.1.3 - - [26/Jan/2010:10:17:06 -0600] [ www.mydomain.com/sid#9094fec][rid#90a8b3c/initial<http://www.mydomain.com/sid#9094fec][rid%2390a8b3c/initial>] (3) applying pattern '/products/(.*)/(.*)\.html$' to uri '/products/whirlpool/1234567.html' 192.168.1.3 - - [26/Jan/2010:10:17:06 -0600] [ www.mydomain.com/sid#9094fec][rid#90a8b3c/initial<http://www.mydomain.com/sid#9094fec][rid%2390a8b3c/initial>] (2) *rewrite /products/whirlpool/1234567.**html -> /perl/ detail.pl?url_name=&model_nbr=* 192.168.1.3 - - [26/Jan/2010:10:17:06 -0600] [ www.mydomain.com/sid#9094fec][rid#90a8b3c/initial<http://www.mydomain.com/sid#9094fec][rid%2390a8b3c/initial>] (3) *split uri=/perl/detail.pl?url_name=&model_nbr= -> uri=/perl/detail.pl, args=url_name=&model_nbr=* 192.168.1.3 - - [26/Jan/2010:10:17:06 -0600] [ www.mydomain.com/sid#9094fec][rid#90a8b3c/initial<http://www.mydomain.com/sid#9094fec][rid%2390a8b3c/initial>] (2) local path result: /perl/detail.pl 192.168.1.3 - - [26/Jan/2010:10:17:06 -0600] [ www.mydomain.com/sid#9094fec][rid#90a8b3c/initial<http://www.mydomain.com/sid#9094fec][rid%2390a8b3c/initial>] (2) prefixed with document_root to /www/perl/mydomain/htdocs/perl/detail.pl 192.168.1.3 - - [26/Jan/2010:10:17:06 -0600] [ www.mydomain.com/sid#9094fec][rid#90a8b3c/initial<http://www.mydomain.com/sid#9094fec][rid%2390a8b3c/initial>] (1) go-ahead with /www/perl/mydomain/htdocs/perl/detail.pl [OK] Note the bolded sections of the log -- the values stored in $1 and $2 are not substituted into the final URL. On the first server, these do get substituted AND they get written to the rewrite_log. Here's the relevant section of the httpd.conf file for the malfunctioning Apache daemon: RewriteEngine On RewriteLog /var/log/apache-perl/rewrite_log.log RewriteLogLevel 3 RewriteRule /products/(.*)/(.*)\.html$ /perl/ detail.pl?url_name=$1&model_nbr=$2 I thought it was possible that there were conflicts with other rules, so I removed all the other RewriteRules and made sure that there were no .htaccess files that applied to this request. I also tried hard-coding the url_name param to "whirlpool", on the theory that mod_rewrite might be happy with 1 substitution param, but no dice. In this case it still declined to substitute "1234567" for $1. This httpd.conf file has no other virtual hosts which might be causing a conflict. Any suggestions as to what might be going on? Thanks, Chris