简体   繁体   English

为什么Heroku修剪后跟斜杠?

[英]Why is Heroku trimming trailing slashes?

I have a Laravel webapp that I am developing for a Heroku environment. 我有一个针对Heroku环境开发的Laravel Webapp。 On the heroku environment, if I visit a url with a trailing slash (IE http://example.com/ ) I get a 301 redirect removing the trailing slash (IE http://example.com ). 在heroku环境中,如果我访问带有斜杠的URL(IE http://example.com/ ),则会得到301重定向,从而删除了斜杠(IE http://example.com )。 This would be fine behavior, except that the rewrite is moving from https to http! 这是很好的行为,除了重写从https转移到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. 我花了一些时间尝试在开发环境中本地重现该问题,但我做不到,这使我相信问题与Heroku的Apache配置有关,但是上传自定义.htaccess却将RewriteEngine关闭并没有阻止该问题。重写之一。

Has anyone encountered a similar issue? 有没有人遇到过类似的问题?

My procfile just contains web: vendor/bin/heroku-php-apache2 public so it's quite minimal. 我的procfile只包含web: vendor/bin/heroku-php-apache2 public所以它很小。

Heroku does not perform such redirects. Heroku不执行此类重定向。 Apache adds slashes for directory indexes if enabled, but that's it. 如果启用,Apache会为目录索引添加斜杠,仅此而已。

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. 您的应用程序正在使用代码或.htaccess某处重定向,并且由于对dyno的请求是HTTP,因此未保留请求协议-SSL的终止发生在负载平衡器处。

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. 设置您的应用程序以将Heroku负载均衡器作为代理信任,以便它从X-Forwarded-Proto读取请求协议,或者更改您的重写规则来做到这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM