RewriteMap 在 mod-rewrite 中不起作用

发布于 2024-09-10 17:53:27 字数 436 浏览 1 评论 0原文

我一直在尝试在 htaccess 中使用 RewriteMap 指令进行简单映射,但由于某种原因我每次都会收到错误 500。我的语法是.. 选项 +FollowSymLinks

RewriteEngine on
RewriteBase /
RewriteMap name2id txt:nklist.txt
RewriteRule ^/name/(.*) /name_list_view.php?kid=${name2id:$1|NOTFOUND}

nklist.txt 中的

1 David
2 Mark
3 Simon

: nklist.txt 文件位于我网站的根目录下,与 htaccess 所在的位置相同。据我的调试告诉我 htaccess 无法找到 nklist.txt 文件,但任何帮助将不胜感激。

I have been trying to do simple maping with RewriteMap directive in my htaccess, but for some reason i am getting error 500 everytime. my syntax is ..
Options +FollowSymLinks

RewriteEngine on
RewriteBase /
RewriteMap name2id txt:nklist.txt
RewriteRule ^/name/(.*) /name_list_view.php?kid=${name2id:$1|NOTFOUND}

in nklist.txt :

1 David
2 Mark
3 Simon

the nklist.txt file is on the root of my website , same place where the htaccess is . As far as my debugging tells me that htaccess is not able to find the nklist.txt file, but any help would be thankful.

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

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

发布评论

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

评论(1

花开浅夏 2024-09-17 17:53:27

根据您的描述,您尝试通过 .htaccess 文件在每个目录上下文中定义 RewriteMap,但这是不允许的。只能定义 RewriteMap在每个服务器上下文中,无论是在主服务器配置中还是在虚拟服务器部分中。

当您向服务器发出请求并解析 .htaccess 文件时,它会遇到 RewriteMap 指令并发出警报,从而导致抛出 500 错误。您可能会在 error_log 中看到一条条目,指出“此处不允许 RewriteMap”。

From your description, you're attempting to define a RewriteMap in a per-directory context via your .htaccess file, but this isn't allowed. The RewriteMap can only be defined in a per-server context, either in the main server configuration or in a virtual server section.

When you make requests to the server and the .htaccess file is parsed, it encounters the RewriteMap directive and issues an alert, which results in an 500 error being thrown. You'll likely see an entry in your error_log that states "RewriteMap not allowed here".

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