重写映射不匹配

发布于 2024-08-15 05:35:55 字数 872 浏览 6 评论 0原文

我的重写映射与事物不匹配时遇到问题:

RewriteMap map txt:rewritemaps\map.txt  [NC]
RewriteCond ${map:$1|NOT_FOUND} !NOT_FOUND [NC]
RewriteRule ^(.+)$  ${map:$1}   [NC, R=301]

该映射大约有 4,500 个条目,包括:

arctic  /Destinations/Polar-Regions/The-Arctic.aspx

我的 RewriteLog,设置为级别 9,日志:

init rewrite engine with requested uri /arctic
Htaccess process request C:\Program Files\ISAPI Rewrite\httpd.conf
Htaccess process request C:\Websites\Path\WebSite\.htaccess
[..]
applying pattern '^(.+)$' to uri 'arctic'
map lookup FAILED: map=map[txt] key=arctic
RewriteCond: input='NOT_FOUND' pattern='NOT_FOUND' =>

它适用于不在映射中的页面 - 例如 /Contact-Us.aspx,但不适用于与应该匹配的东西(例如北极)。我尝试更改 [NC] 标志的位置,删除 RewriteCond 并重命名地图文件(以防“map”是保留关键字)。没有喜悦。这似乎也不是权限问题。

仅供参考,我使用的是 Helicontech 的 ISAPIRewrite,因为我使用的是 IIS6。

I'm having trouble with my rewritemap not matching things:

RewriteMap map txt:rewritemaps\map.txt  [NC]
RewriteCond ${map:$1|NOT_FOUND} !NOT_FOUND [NC]
RewriteRule ^(.+)$  ${map:$1}   [NC, R=301]

The map has about 4,500 entries, including:

arctic  /Destinations/Polar-Regions/The-Arctic.aspx

My RewriteLog, set to level 9, logs:

init rewrite engine with requested uri /arctic
Htaccess process request C:\Program Files\ISAPI Rewrite\httpd.conf
Htaccess process request C:\Websites\Path\WebSite\.htaccess
[..]
applying pattern '^(.+)

It works with pages not in the map - eg /Contact-Us.aspx, but not with stuff which should match (such as arctic). I've tried changing location of the [NC] flag, removing the RewriteCond and renaming the map file (just in case 'map' was a reserved keyword). No joy. It also doesn't seem to be a permissions problem.

FYI, I'm using ISAPIRewrite by Helicontech as I'm on IIS6.

to uri 'arctic' map lookup FAILED: map=map[txt] key=arctic RewriteCond: input='NOT_FOUND' pattern='NOT_FOUND' =>

It works with pages not in the map - eg /Contact-Us.aspx, but not with stuff which should match (such as arctic). I've tried changing location of the [NC] flag, removing the RewriteCond and renaming the map file (just in case 'map' was a reserved keyword). No joy. It also doesn't seem to be a permissions problem.

FYI, I'm using ISAPIRewrite by Helicontech as I'm on IIS6.

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

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

发布评论

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

评论(3

浅暮の光 2024-08-22 05:35:55

三个建议:

  1. 尝试使用正斜杠 (/) 作为目录分隔符。
  2. 如果这不起作用,请尝试完全限定的路径。
  3. 尝试不使用 RewriteCond。

Three suggestions:

  1. Try using a forward slash (/) as the directory separator.
  2. If that doesn't work, try a fully-qualified path.
  3. Try it without the RewriteCond.
压抑⊿情绪 2024-08-22 05:35:55

如果map.txt与.htaccess位于同一文件夹中,请尝试以下定义:

RewriteMap map txt:map.txt  [NC]

如果位于其他位置,请尝试使用完全限定路径。

如果您还没有使用 ISAPI_Rewrite,请考虑更新到最新版本。

If map.txt is in the same folder with .htaccess, please try the following definition:

RewriteMap map txt:map.txt  [NC]

If it's in another location, please try to use fully-qualified path.

Also please consider updating to the latest build of ISAPI_Rewrite if you are not on it yet.

ゞ花落谁相伴 2024-08-22 05:35:55

我遇到了同样的问题并用“”修复了它,尝试:

RewriteMap map "txt:rewritemaps\map.txt"  [NC]
RewriteCond ${map:$1|NOT_FOUND} !NOT_FOUND [NC]
RewriteRule "^(.+)$"  "${map:$1}"   [NC, R=301]

I had the same issue and fixed it with "", try:

RewriteMap map "txt:rewritemaps\map.txt"  [NC]
RewriteCond ${map:$1|NOT_FOUND} !NOT_FOUND [NC]
RewriteRule "^(.+)$"  "${map:$1}"   [NC, R=301]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文