【问题标题】:Error 500 when I have RewriteMap in .htaccess当我在 .htaccess 中有 RewriteMap 时出现错误 500
【发布时间】:2011-12-18 23:58:37
【问题描述】:

我有一个这种格式的地图文件

233 Alabama/Phenix-City/Ridgebrook
237 Alabama/Ft.-Mitchell/Riverside-Estates

我有以下 .htaccess 脚本。当有问题的页面被点击时,我收到 500 内部服务器错误。

RewriteEngine On
RewriteBase /
Options +FollowSymLinks

RewriteMap examplemap txt:/var/www/html/site.com/key_pair.txt
RewriteRule community.php?(.*) ${examplemap:$1} [R]

当我传递以下 URL 时,我希望它被重写如下。

http://example.com/community.php?comm_id=233    

应该这样改写

http://example.com/Alabama/Phenix-City/Ridgebrook

有什么想法吗?

【问题讨论】:

  • 您可以只使用相对路径,因此只需 txt:key_pair.txt。对于可能导致问题的原因没有其他想法。
  • 看来该站点无法通过 RewriteMap 规则访问。我刚刚测试了其他页面,无法访问其中任何一个。一旦我注释掉站点运行的 .htaccess 文件中的行。
  • 我想知道 RewriteMap 是放在 .htacess 文件中还是其他地方。

标签: apache .htaccess url-rewriting rewritemap


【解决方案1】:

您不能在 .htaccess 文件中包含 RewriteMap:

http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritemap

仅在服务器配置(如 httpd.conf)和您的虚拟主机配置文件中可用。

【讨论】:

  • 谢谢我想通了。被告知我在 8 小时内无法回答自己的问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-08-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-08-13
相关资源
最近更新 更多