某些URL太长而无法访问应用程序

时间:2018-10-16 01:20:09

标签: php apache

我最近安装了PHP7.1,并且在手边的应用程序中遇到了一些问题。看来,一旦URL超过108个字符,该请求就不会像未正确路由一样命中该应用程序。 我认为有一个我缺少的php.ini设置正在启用此行为。但是,我找不到任何有效的方法。我在其他地方看到有人建议增加或关闭php.ini中的“ output_buffering”,但这没用。

任何帮助,不胜感激!

这是htaccess代码:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]

检查apache错误日志当请求以我描述的方式失败时,出现以下错误:

[Tue Oct 16 17:05:38.000118 2018] [core:notice] [pid 77] AH00052: child pid 26760 exit signal Segmentation fault (11)
[Tue Oct 16 17:05:38.000542 2018] [core:notice] [pid 77] AH00052: child pid 26759 exit signal Bus error (10)
[Tue Oct 16 17:05:39.074451 2018] [core:notice] [pid 77] AH00052: child pid 26761 exit signal Bus error (10)
[Tue Oct 16 17:05:40.089130 2018] [core:notice] [pid 77] AH00052: child pid 26763 exit signal Segmentation fault (11)
[Tue Oct 16 17:05:40.092705 2018] [core:notice] [pid 77] AH00052: child pid 26762 exit signal Segmentation fault (11)
[Tue Oct 16 17:05:41.195042 2018] [core:notice] [pid 77] AH00052: child pid 26767 exit signal Segmentation fault (11)
[Tue Oct 16 17:05:41.195139 2018] [core:notice] [pid 77] AH00052: child pid 26766 exit signal Bus error (10)
[Tue Oct 16 17:05:41.195381 2018] [core:notice] [pid 77] AH00052: child pid 26765 exit signal Segmentation fault (11)
[Tue Oct 16 17:05:41.195456 2018] [core:notice] [pid 77] AH00052: child pid 26764 exit signal Segmentation fault (11)
[Tue Oct 16 17:05:42.257230 2018] [core:notice] [pid 77] AH00052: child pid 26768 exit signal Segmentation fault (11)

有效网址为:

http://photospace.local/admin/content/pages?sdkjfhksdjhfjk=sdfkjnasdasdasdsaasdasdsadadfdfafdgfg

一个不工作的人将是(请注意,这个人只有一个字符):

http://photospace.local/admin/content/pages?sdkjfhksdjhfjk=sdfkjnasdasdasdsaasdasdsadadfdfafdgfaf

2 个答案:

答案 0 :(得分:0)

我通过从Apache的LoadModule negotiation_module libexec/apache2/mod_negotiation.so删除httpd.conf来解决了该问题

我希望它对其他人有帮助,因为它是如此晦涩,只是偶然解决了。

欢呼

答案 1 :(得分:0)

以上答案不是解决方案,它确实解决了某些情况,但并非全部。大量URL模式失败,或提交表单后POST请求。我以前从未遇到过这个问题(使用上面的.htaccess配置),直到我全新安装了最新的Mac OSX 10.3.6并升级到PHP7.2

摆弄.htaccess配置后,我发现以下内容解决了所有问题:

Options +FollowSymlinks
RewriteEngine On

# removes www.
# ------------------------------------------------------------------
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]

# rewrite "domain.com/foo -> domain.com/foo/"
# ------------------------------------------------------------------
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$
RewriteRule ^(.*)$ /$1/ [R=301,L]

# Yii specific rewrite
# ------------------------------------------------------------------
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php 

#RewriteRule ^(.*)$ index.php [QSA,L]