<small id='fzUpY'></small><noframes id='fzUpY'>

  • <legend id='fzUpY'><style id='fzUpY'><dir id='fzUpY'><q id='fzUpY'></q></dir></style></legend>
    • <bdo id='fzUpY'></bdo><ul id='fzUpY'></ul>

    1. <tfoot id='fzUpY'></tfoot>
      <i id='fzUpY'><tr id='fzUpY'><dt id='fzUpY'><q id='fzUpY'><span id='fzUpY'><b id='fzUpY'><form id='fzUpY'><ins id='fzUpY'></ins><ul id='fzUpY'></ul><sub id='fzUpY'></sub></form><legend id='fzUpY'></legend><bdo id='fzUpY'><pre id='fzUpY'><center id='fzUpY'></center></pre></bdo></b><th id='fzUpY'></th></span></q></dt></tr></i><div id='fzUpY'><tfoot id='fzUpY'></tfoot><dl id='fzUpY'><fieldset id='fzUpY'></fieldset></dl></div>

      1. Symfony:电子邮件地址作为请求参数

        Symfony: email address as request parameter(Symfony:电子邮件地址作为请求参数)

          <small id='NLPAy'></small><noframes id='NLPAy'>

            1. <tfoot id='NLPAy'></tfoot>
                <tbody id='NLPAy'></tbody>
                <bdo id='NLPAy'></bdo><ul id='NLPAy'></ul>

                  <i id='NLPAy'><tr id='NLPAy'><dt id='NLPAy'><q id='NLPAy'><span id='NLPAy'><b id='NLPAy'><form id='NLPAy'><ins id='NLPAy'></ins><ul id='NLPAy'></ul><sub id='NLPAy'></sub></form><legend id='NLPAy'></legend><bdo id='NLPAy'><pre id='NLPAy'><center id='NLPAy'></center></pre></bdo></b><th id='NLPAy'></th></span></q></dt></tr></i><div id='NLPAy'><tfoot id='NLPAy'></tfoot><dl id='NLPAy'><fieldset id='NLPAy'></fieldset></dl></div>

                1. <legend id='NLPAy'><style id='NLPAy'><dir id='NLPAy'><q id='NLPAy'></q></dir></style></legend>
                  本文介绍了Symfony:电子邮件地址作为请求参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在将 url 中的电子邮件地址传递给 symfony 应用程序时遇到了一些问题.

                  I'm having some issues with passing an email address in a url to a symfony app.

                  网址看起来像

                  example.com/unsubscribe/email/me@example.com
                  

                  它总是会导致 sfError404Exception,除非删除了句点.在进行了一些谷歌搜索之后,我看到的唯一解决方案是 htaccess 由于存在时间段而绕过了 url.但是,当我将建议的修复添加到 htaccess 时,如下所示:

                  It will always result in a sfError404Exception, except when the period is removed. After doing some googling around, the only solution I've yet seen is that htaccess is bypassing the url because of the period present. However, when I add the suggested fix to htaccess, like so:

                  # 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 (example.com/index.php/unsubscribe/email/me@example.com) 中使用前端控制器时,它也会返回 404.我试过将转义版本直接放入地址栏,例如 example.com/unsubscribe/me%40example%2Ecom 并且这有效,但仅在 Firefox 中,没有其他地方.

                  I get the same 404. It also returns 404 when I use the front controller directly in the url (example.com/index.php/unsubscribe/email/me@example.com). I've tried putting the escaped version directly into the address bar, eg example.com/unsubscribe/me%40example%2Ecom and this works, but only in firefox, nowhere else.

                  此时我已经在论坛上用了大约 2 个小时的谷歌搜索来回答问题,但我的想法已经用完了.

                  I've spent about 2 hours in forum answer googling hell at this point and I'm running out of ideas.

                  有什么想法吗?

                  谢谢.

                  更新:这是routing.yml的相关部分:

                  Update: Here is the relevant section of the routing.yml:

                  unsubscribeform:
                    url:  /unsubscribe/email/:email
                    param: { module: subscribe, action: index }
                  

                  更新:堆栈跟踪......看起来它没有得到任何路由信息给我

                  Update: Stack trace ... looks like its not getting any route information to go on to me

                  404 | Not Found | sfError404Exception
                  Empty module and/or action after parsing the URL "/unsubscribe/email/me@example.com" (/).
                  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.

                  推荐答案

                  默认情况下,Symfony 将 ./ 视为参数分隔符.
                  这使得匹配这样的网址变得非常容易:

                  By default, Symfony treats . and / as parameter separators.
                  That makes it very easy to match a url like so:

                  /some/path/:param.:ext
                  

                  但对电子邮件地址没有帮助.

                  But doesn't help with email addresses.

                  幸运的是,您可以通过指定自己的模式来覆盖 . 分隔符.
                  只需将下面的 requirements 行添加到您的路由中:

                  Fortunately, you can override the . separator by specifying your own pattern.
                  Just add the requirements line below to your routing:

                  unsubscribeform:
                    url:  /unsubscribe/email/:email
                    param: { module: subscribe, action: index }
                    requirements: { email: .+ }
                  

                  需求中的 .+ 是一个匹配任何东西的正则表达式..匹配任意字符,+表示匹配一个或多个.

                  The .+ in the requirement is a regular expression matching anything. The .matches any character, and the + means match one-or-more.

                  (在 Symfony 1.4 中测试)

                  (Tested in Symfony 1.4)

                  这篇关于Symfony:电子邮件地址作为请求参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                2. <small id='dLf37'></small><noframes id='dLf37'>

                      <tbody id='dLf37'></tbody>

                      <tfoot id='dLf37'></tfoot>
                      <legend id='dLf37'><style id='dLf37'><dir id='dLf37'><q id='dLf37'></q></dir></style></legend>
                          <bdo id='dLf37'></bdo><ul id='dLf37'></ul>
                          <i id='dLf37'><tr id='dLf37'><dt id='dLf37'><q id='dLf37'><span id='dLf37'><b id='dLf37'><form id='dLf37'><ins id='dLf37'></ins><ul id='dLf37'></ul><sub id='dLf37'></sub></form><legend id='dLf37'></legend><bdo id='dLf37'><pre id='dLf37'><center id='dLf37'></center></pre></bdo></b><th id='dLf37'></th></span></q></dt></tr></i><div id='dLf37'><tfoot id='dLf37'></tfoot><dl id='dLf37'><fieldset id='dLf37'></fieldset></dl></div>