RewriteMap MapType dbd 的问题

发布于 2024-12-03 10:28:54 字数 1168 浏览 1 评论 0原文

继续这里的另一个讨论:

MySQL + htaccess mod_rewrite?

我被要求开始另一个问题。

我将其添加到我的 httpd.conf 文件中:

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

当我尝试重新启动 Apache 时,出现此错误:

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

看起来它完全忽略了 dbd 部分并尝试将整个内容作为文件名读取。我真的不知道我做错了什么。

更新

我尝试简化这一点,只使用地图的直接文本文件:

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

根目录中有一个文本文件,其中仅包含以下内容:

232 The+Pillar+of+Autumn+LASO

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

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

因此访问路径 ch232 应重定向到/challenge/232/The+Pillar+of+Autumn+LASO,但它只是重定向到 /challenge/232/,没有标题。我到底做错了什么?!?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如何视而不见 2024-12-10 10:28:54

我发现 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文