我在将 url 中的电子邮件地址传递到 symfony 应用程序时遇到一些问题。
网址看起来像
example.com/unsubscribe/email/[email protected]
它总是会导致一个sfError404Exception
,除非删除句点。在进行了一些谷歌搜索后,我见过的唯一解决方案是 htaccess 由于存在句点而绕过了 url。但是,当我将建议的修复添加到 htaccess 时,如下所示:
# we skip all files with .something
RewriteCond %{REQUEST_URI} \..+$
RewriteCond %{REQUEST_URI} !@.+ #skip email address
RewriteCond %{REQUEST_URI} \.epl$
RewriteCond %{REQUEST_URI} !\.html$
RewriteCond %{REQUEST_URI} !\.rhtml$
RewriteRule .* - [L]
我得到相同的 404。当我直接在 url 中使用前端控制器时,它也会返回 404(example.com/index.php/unsubscribe/email/[email protected]
)。我尝试将转义版本直接放入地址栏,例如example.com/unsubscribe/me%40example%2Ecom
这有效,但仅在 Firefox 中有效,在其他地方无效。
我已经花了大约 2 个小时在论坛上回答谷歌搜索,此时我已经没有想法了。
有什么想法吗?
Thanks.
更新:这是routing.yml的相关部分:
unsubscribeform:
url: /unsubscribe/email/:email
param: { module: subscribe, action: index }
Update:堆栈跟踪...看起来它没有得到任何路由信息来继续我的工作
404 | Not Found | sfError404Exception
Empty module and/or action after parsing the URL "/unsubscribe/email/[email protected]" (/).
stack trace
1. at ()
in SF_SYMFONY_LIB_DIR/controller/sfFrontWebController.class.php line 44 ...
41.
42. if (empty($moduleName) || empty($actionName))
43. {
44. throw new sfError404Exception(sprintf('Empty module and/or action after parsing the URL "%s" (%s/%s).', $request->getPathInfo(), $moduleName, $actionName));
45. }
46.
47. // make the first request
2. at sfFrontWebController->dispatch()
in SF_SYMFONY_LIB_DIR/util/sfContext.class.php line 159 ...
156. */
157. public function dispatch()
158. {
159. $this->getController()->dispatch();
160. }
161.
162. /**
3. at sfContext->dispatch()
in /home/web/htdocs/index.php line 10 ...
7. require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'ProjectConfiguration.class.php');
8.
9. $configuration = ProjectConfiguration::getApplicationConfiguration(SF_APP, SF_ENVIRONMENT, SF_DEBUG);
10. sfContext::createInstance($configuration)->dispatch();
11.