与RewriteMap指令的MapType DBD问题 [英] Problems with RewriteMap MapType dbd

查看:171
本文介绍了与RewriteMap指令的MapType DBD问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是另一个讨论继续在这里:

Continuing from another discussion here:

的MySQL + htaccess的mod_rewrite的?

如果有人问我,开始了另一个问题。

Where I was asked to start another question.

我说这我的httpd.conf文件:

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"

当我试图重新启动Apache我得到这个错误:

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

它看起来像它完全无视 DBD 部分,并试图读取整个事情作为一个文件名。我真的不知道我做错了。

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.

更新

我试图简化这一点,只是使用直文本文件供图:

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

RewriteMap指令HRCI TXT:/home/username/rewrite.txt

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

有一个在根目录下的文本文件,它包含简单:

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

232 +中秋+ LASO的+柱+

232 The+Pillar+of+Autumn+LASO

最后,我有我的重写规则:

And finally, I have my rewrite rule:

重写规则^ CH([0-9] {1,4})(/)$ 的http:/ /reachchallenges.infectionist.com/challenge/ $ 1 / $ {HRCI:$ 1} [R = 301,L]

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

所以访问路径 ch232 应重定向到 /挑战/ 232 /的+中秋+ LASO的+柱+ ,而是它只是重定向到 /挑战/ 232 / ,没有标题。你到底我做错了?!?

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?!?

推荐答案

我发现,为什么在RewriteMap指令的DBD部分不工作(至少对我来说)的原因是,它应该只从Apache的工作2.3+ 。对于我的Apache2.2,这是行不通的。

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.

这篇关于与RewriteMap指令的MapType DBD问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆