RewriteMap - am I going mad?
RewriteMap - am I going mad?
am 16.11.2007 19:37:10 von BlueC
Hi folks, please help with my RewriteMap problem - it's driving me
insane!
Here's what I have...
In httpd.conf outside any VirtualHost and outside any Directory
directives:
RewriteMap catmap txt:/etc/httpd/conf/categories.txt
which points (correctly) to a plain text file that contains these two
mappings:
66 calendars-and-time-keeping
90 security-and-backup
Now, later on in the httpd.conf, inside a directive I have
the following RewriteRule:
RewriteBase /example
RewriteEngine on
RewriteRule ^cat([0-9]*).html ${catmap:$1|cant-find},
$1,C.html [R]
But when I hit the URL http://www.example.com/example/cat66.html it
redirects me to http://www.example.com/example/cant-find,66,C.html and
the same for cat90.html. So it's not finding the key to lookup in the
map file...?!!?!
Why is it doing this? I've tried every permutation of options I can
think of, but nothing I do seems to make RewriteMap actually lookup
and find the values in the map file.
Re: RewriteMap - am I going mad?
am 16.11.2007 22:03:48 von HansH
"BlueC" schreef in bericht
news:7db0eff1-ed56-4ea7-be8f-763782adedff@f3g2000hsg.googleg roups.com...
> RewriteMap catmap txt:/etc/httpd/conf/categories.txt
> 66 calendars-and-time-keeping
> 90 security-and-backup
>
> Now, later on in the httpd.conf, inside a directive I have
> the following RewriteRule:
>
> RewriteBase /example
> RewriteEngine on
> RewriteRule ^cat([0-9]*).html ${catmap:$1|cant-find}, $1,C.html [R]
>
> But when I hit the URL http://www.example.com/example/cat66.html it
> redirects me to http://www.example.com/example/cant-find,66,C.html and
> the same for cat90.html. So it's not finding the key to lookup in the
> map file...?!!?!
So the rule works, but the key cannt be found in the map.
The username in use by apache need to be able to read the file
etc/httpd/conf/categories.txt
If the file is inaccessable Apache wil *not* croak ...
If the file is missing Apache won't (re)start ...
HansH
Re: RewriteMap - am I going mad?
am 17.11.2007 12:34:05 von BlueC
On Nov 16, 9:03 pm, "HansH" wrote:
>
> So the rule works, but the key cannt be found in the map.
>
> The username in use by apache need to be able to read the file
> etc/httpd/conf/categories.txt
>
> If the file is inaccessable Apache wil *not* croak ...
> If the file is missing Apache won't (re)start ...
>
> HansH
Hi HansH, thanks for responding.
I had suspected permissions too but I have double checked and the file
is readable by apache. Apache runs under the user "apache" and I have
even tried changing the file ownership and group to apache - still no
dice.
For example, the file /etc/httpd/conf/categories.txt has permissions
as follows...
-rw-r--r-- 1 apache apache 50 Nov 17 11:25 categories.txt
The directory /etc/httpd/conf/ is definitely readable by apache since
that is where the config files are! As you say, it's processing the
rule but not finding the key in the file. It's driving me nuts!
I'm tempted to give up on RewriteMap and just redirect to a script
that will further process the redirects.
Re: RewriteMap - am I going mad?
am 17.11.2007 17:31:09 von HansH
"BlueC" schreef in bericht
news:bff199e3-a9d7-4c10-9e38-5b783bf6a77d@l22g2000hsc.google groups.com...
> I had suspected permissions too but I have double checked and the file
> is readable by apache. Apache runs under the user "apache" and I have
> even tried changing the file ownership and group to apache - still no
> dice.
>
> For example, the file /etc/httpd/conf/categories.txt has permissions
> as follows...
>
> -rw-r--r-- 1 apache apache 50 Nov 17 11:25 categories.txt
>
> The directory /etc/httpd/conf/ is definitely readable by apache since
> that is where the config files are!
Apache might be able to read the folder during startup, but may fail later!
Be aware apache starts as root, thus will be able to read anything.
However, during startup ownership of the process is transferred to 'apache'
and hence it may loose its ability to read the file or to list the folder
holding it.
A mapping file is not red untill a request is processed that satisfies a
rule referring the corresponding mapping...
> I'm tempted to give up on RewriteMap and just redirect to a script
> that will further process the redirects.
Consider to move the file to the folder just above document root.
To me this mapping feels more like content than configuration anyway.
HansH
Re: RewriteMap - am I going mad?
am 22.11.2007 19:25:50 von BlueC
On Nov 17, 4:31 pm, "HansH" wrote:
> "BlueC" schreef in berichtnews:bff199e3-a9d7-4c10-9e38-5b783bf6a77d@l22g2000hsc .googlegroups.com...> I had suspected permissions too but I have double checked and the file
> > is readable by apache. Apache runs under the user "apache" and I have
> > even tried changing the file ownership and group to apache - still no
> > dice.
>
> > For example, the file /etc/httpd/conf/categories.txt has permissions
> > as follows...
>
> > -rw-r--r-- 1 apache apache 50 Nov 17 11:25 categories.txt
>
> > The directory /etc/httpd/conf/ is definitely readable by apache since
> > that is where the config files are!
>
> Apache might be able to read the folder during startup, but may fail later!
> Be aware apache starts as root, thus will be able to read anything.
> However, during startup ownership of the process is transferred to 'apache'
> and hence it may loose its ability to read the file or to list the folder
> holding it.
> A mapping file is not red untill a request is processed that satisfies a
> rule referring the corresponding mapping...
>
> > I'm tempted to give up on RewriteMap and just redirect to a script
> > that will further process the redirects.
>
> Consider to move the file to the folder just above document root.
> To me this mapping feels more like content than configuration anyway.
>
> HansH
Thanks HansH - that's useful info. When I have time I'll look into
this again, meanwhile I gave up with it and just redirected matching
requests to a script which further redirected them.