dongshi9526 2014-10-16 06:23
浏览 40

长URL挂起PHP页面

I'm hosting my PHP web site on a shared web hosting account, so I'm not sure what may be causing this since I don't have direct access to the server.

The page in question is very simple. Its PHP script receives data via a GET request and fills out the form on the page with it (as defaults before the user fills out the rest.)

For instance, it may accept a URL as such:

http://www.example.com/test.php?id=sendform&name=somename&ver=1.0&desc=some%20description

Then the PHP script reads parameters passed to it (via functions like stripslashes($_REQUEST['desc']);) and creates the HTML markup with form fields filled out with the data passed to it.

So this was working fine, until I noticed that if I pass a long URL (I don't know the exact limit, but for instance my test URL is 1,280 characters long) the script in my test.php does not execute and the page hangs up for a long time until the browser times out with an error.

I first thought that the stripslashes($_REQUEST['desc']); call was to blame, and thus I stripped out everything except a simply line:

print("Got to the end");

which still got hung up with a long URL.

So I'm curious, why is this happening? And how to prevent this "hang up"?

  • 写回答

1条回答 默认 最新

  • dongpao2871 2014-10-16 06:34
    关注

    You ideally shouldn't have long URLs as the recommended limit is to not have more than 256 characters including host as well. It is hard to figure out based on the information you have provided, but it could be possibly because of

    1. Browser (Check request trapping tools and see if the request is really being sent or getting blocked by browser itself.
    2. Server (Server may have limit over the url length in the configuration, you can check the access log OR error log to get the details)
    3. Settings at firewall (firewall at the server may be preventing such longer URL)

    A suggestion is to avoid longer URL and if possible use POST method to send the data.

    评论

报告相同问题?

悬赏问题

  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助
  • ¥15 STM32控制MAX7219问题求解答