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 MATLAB代码补全插值
  • ¥15 Typegoose 中如何使用 arrayFilters 筛选并更新深度嵌套的子文档数组信息
  • ¥15 前后端分离的学习疑问?
  • ¥15 stata实证代码答疑
  • ¥50 husky+jaco2实现在gazebo与rviz中联合仿真
  • ¥15 dpabi预处理报错:Error using y_ExtractROISignal (line 251)
  • ¥15 在虚拟机中配置flume,无法将slave1节点的文件采集到master节点中
  • ¥15 husky+kinova jaco2 仿真
  • ¥15 zigbee终端设备入网失败
  • ¥15 金融监管系统怎么对7+4机构进行监管的