• <small id='F4u4W'></small><noframes id='F4u4W'>

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

        Laravel:如何在重定向到任何网址时设置自定义标头

        Laravel: How to set custom header while redirecting to any url(Laravel:如何在重定向到任何网址时设置自定义标头)

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

      1. <tfoot id='bBEXd'></tfoot>

            <tbody id='bBEXd'></tbody>
          <legend id='bBEXd'><style id='bBEXd'><dir id='bBEXd'><q id='bBEXd'></q></dir></style></legend>
          <i id='bBEXd'><tr id='bBEXd'><dt id='bBEXd'><q id='bBEXd'><span id='bBEXd'><b id='bBEXd'><form id='bBEXd'><ins id='bBEXd'></ins><ul id='bBEXd'></ul><sub id='bBEXd'></sub></form><legend id='bBEXd'></legend><bdo id='bBEXd'><pre id='bBEXd'><center id='bBEXd'></center></pre></bdo></b><th id='bBEXd'></th></span></q></dt></tr></i><div id='bBEXd'><tfoot id='bBEXd'></tfoot><dl id='bBEXd'><fieldset id='bBEXd'></fieldset></dl></div>
            • <bdo id='bBEXd'></bdo><ul id='bBEXd'></ul>
                  本文介绍了Laravel:如何在重定向到任何网址时设置自定义标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 Laravel 5.0 并尝试重定向到带有自定义标头的 url.但不知何故,我没有在重定向页面中获取标题值,或者我们可以说在重定向时没有发送标题值.

                  I am using Laravel 5.0 and trying to redirect to a url with custom headers. But somehow I am not getting the header value in redirected page or we can say header value is not getting sent while redirecting.

                  我正在使用此代码:

                  return redirect('http://www.anydomain.com')
                              ->header('customvalue1', $customvalue1)
                              ->header('customvalue2', $customvalue2);
                  

                  如果我做错了什么,请告诉我.

                  Please let me know if I'm doing something wrong.

                  推荐答案

                  恐怕,其他答案完全错误且具有误导性.

                  I'm afraid, the other answer is completely wrong and misleading.

                  无论您使用什么语言或框架,都无法重定向到设置了自定义标题的页面.换句话说,没有办法触发 HTTP 重定向并导致客户端(浏览器)添加自定义标头.

                  It's impossible to redirect to a page with custom headers set, no matter what language or framework you use. In other words, there's no way to trigger an HTTP redirect and cause the client (browser) to add a custom header.

                  您可能认为这段代码应该可以正常工作:

                  You might be thinking that this code should work just fine:

                  return redirect('http://www.anydomain.com')
                       ->header('customvalue1', $customvalue1)
                       ->header('customvalue2', $customvalue2);
                  

                  但它不会.您正在为指示浏览器重定向的响应设置自定义标头,而不是为重定向本身.

                  But it won't. You're setting the custom headers for the response which is instructing the browser to redirect, not for the redirect itself.

                  站点指示浏览器发出带有自定义标头的 HTTP 请求的唯一方法是使用 Javascript 和 XMLHttpRequest 对象.它需要在目标服务器上实现 CORS 以允许此类 ajax 请求.

                  The only way for a site to instruct a browser to issue an HTTP request with a custom header is to use Javascript and the XMLHttpRequest object. And it needs CORS implemented on the target server to allow such ajax requests.

                  请注意,页面不能设置 HTTP 请求标头,除非它使用 XMLHttpRequest 发出异步请求.这意味着您也不能在客户端使用自定义标头进行此类重定向.

                  Please note that a page can not set HTTP request headers unless it's making an async request using XMLHttpRequest. Meaning that you can't do such redirection with the custom header on the client-side as well.

                  这不是网络的运作方式.

                  That's not how the web works.

                  这篇关于Laravel:如何在重定向到任何网址时设置自定义标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 的问题)
                  • <bdo id='UvQJm'></bdo><ul id='UvQJm'></ul>
                    <legend id='UvQJm'><style id='UvQJm'><dir id='UvQJm'><q id='UvQJm'></q></dir></style></legend>

                            <tbody id='UvQJm'></tbody>

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

                            <tfoot id='UvQJm'></tfoot>

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