drsw9390405 2016-02-08 21:48
浏览 31
已采纳

为什么Heroku修剪拖尾斜线?

I have a Laravel webapp that I am developing for a Heroku environment. On the heroku environment, if I visit a url with a trailing slash (I.E. http://example.com/) I get a 301 redirect removing the trailing slash (I.E. http://example.com). This would be fine behavior, except that the rewrite is moving from https to http!

I've spent some time trying to reproduce the issue locally in my development environment and I cannot, which has led me to believe that the issue is with Heroku's configuration of Apache, but uploading a custom .htaccess turning RewriteEngine Off didn't stop the rewrite either.

Has anyone encountered a similar issue?

My procfile just containsweb: vendor/bin/heroku-php-apache2 public so it's quite minimal.

  • 写回答

1条回答 默认 最新

  • dragon2025 2016-02-14 09:51
    关注

    Heroku does not perform such redirects. Apache adds slashes for directory indexes if enabled, but that's it.

    Your application is doing that redirect somewhere, either in code or a .htaccess, and the request protocol is not preserved because the request to the dyno was HTTP - termination of SSL happens at the load balancer.

    Set up your application to trust the Heroku load balancer as a proxy so it reads the request protocol from X-Forwarded-Proto, or change your rewrite rules to do just that.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记