zend-framework - URL 编码的参数破坏了默认的 Zend 重写规则

标签 zend-framework .htaccess mod-rewrite url-rewriting urlencode

我正在使用标准 Zend /public/.htaccess文件(如下所示)。

目前,我正在尝试将用户转发到特定的 Controller /操作,并将成功重定向 URL 作为 URL 参数提供。

生成的 URL(通过 Zend 的 URL View 助手组合和编码)如下所示:

localhost/crop/index/successRedirect/localhost%2Fprofile%2Fbasic

然而,这种模式显然违反了默认的 Zend 包 mod_rewrite 规则:访问 URL 会产生标准的 Apache 404 错误; Zend 没有收到请求。

当最终参数按如下方式手动重新形成时,请求将按预期工作:
localhost/crop/index/?successRedirect=localhost%2Fprofile%2Fbasic

然而,这需要一个骇人听闻的两步 URL 生成过程。如果 View 助手生成的 URL 独立工作,那将是理想的。

可以做些什么来允许 url 编码通过? 任何见解将不胜感激!

这些是我的 .htaccess 的内容
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

像这样启用 RewriteLog 不会为失败的模式产生输出:
RewriteLogLevel 9
RewriteLog "<path>/rewrite.log"

我已经尝试了以下两个问答提出的解决方案,没有任何变化:
  • Adding encoded chars to the url breaks htaccess ( AllowEncodedSlashes On )
  • Mod Rewrite and Using PHP's GET for URL's When not Following the Rules (使用 QSA 指令重写规则)
  • 最佳答案

    AllowEncodedSlashes On使用您的确切测试 URL 为我修复了此问题。但是根据 http://httpd.apache.org/docs/2.0/mod/core.html#allowencodedslashes ,此指令需要在服务器配置或 vhost 中。它在 .htaccess 文件中不起作用。

    我个人会使用查询字符串解决方案。您能否详细说明这是一个两步 URL 生成过程的含义?我原以为语法与使用普通 URL 助手非常相似。

    关于zend-framework - URL 编码的参数破坏了默认的 Zend 重写规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9120721/

    相关文章:

    php - 如何将 get 字符串转换为 slug?

    .htaccess GET 参数值到 index.php

    apache - 如何使用别名重写规则?

    javascript - timezone.js 在 zend 框架 2 中不工作

    jquery - Uploadify 不适用于受密码保护的网站

    php - 向包含数千个链接 HTML 文件的文件夹添加通用 header 和身份验证系统

    css - 无法识别我的 css、js 等

    zend-framework - Zend Framework 将条形码渲染为 PDF 页面

    jquery - SSL CORS 不适用于 Zend Guard

    php - 如何在 Windows 8 的 xmpp 中安装 zend