Problems with RewriteMap MapType dbd

2019-08-27 09:49发布

Continuing from another discussion here:

MySQL + htaccess mod_rewrite?

Where I was asked to start another question.

I added this to my httpd.conf file:

DBDriver mysql
DBDParams "host=*****,user=*****,pass=*****,dbname=*****"
RewriteEngine On
RewriteMap hrci "dbd:SELECT title FROM challenges WHERE id = %s"

When I tried to restart Apache I got this error:

RewriteMap: file for map hrci not found:/dh/apache2/apache2-ps54462/dbd:SELECT title FROM challenges WHERE id = %s

It looks like it's completely ignoring the dbd part and trying to read the whole thing as a file name. I really don't know what I'm doing wrong.

UPDATE

I tried simplifying this and just using a straight text file for the map:

RewriteMap hrci txt:/home/username/rewrite.txt

There is a text file in the root directory that contains simply this:

232 The+Pillar+of+Autumn+LASO

And finally, I have my rewrite rule:

RewriteRule ^ch([0-9]{1,4})(/)?$ http://reachchallenges.infectionist.com/challenge/$1/${hrci:$1} [R=301,L]

So visiting the path ch232 should redirect to /challenge/232/The+Pillar+of+Autumn+LASO, but instead it just redirects to /challenge/232/, no title. What the heck am I doing wrong?!?

1条回答
相关推荐>>
2楼-- · 2019-08-27 09:55

I found out that the reason why the dbd part in the RewriteMap is not working (at least for me) is that it should be working only from apache 2.3+. For my apache2.2, it does not work.

查看更多
登录 后发表回答