Problems with RewriteMap MapType dbd

浪尽此生 提交于 2019-12-25 03:54:07

问题


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:


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.



来源:https://stackoverflow.com/questions/7329212/problems-with-rewritemap-maptype-dbd

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!