使用PHP通过表单发布URL时触发错误403 [英] Error 403 triggered when posting URL's via form with PHP

查看:111
本文介绍了使用PHP通过表单发布URL时触发错误403的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在apache共享主机上使用PHP通过表单发布URL时遇到403 Forbidden错误。

I am encountering a 403 Forbidden error when posting URL's via a form using PHP on an apache shared host.

来自现有问题(表单提交错误403 )这很可能是由服务器上安装的mod_security引起的。

From an existing question ( Error 403 on form submit ) this is most likely caused by mod_security installed on the server.

当我使用共享主机时,我无法轻松禁用模块,因此我实现了 JavaScript解决方案,用于在发布数据之前删除 http://

As I am using shared hosting, I'm not able to disable the module easily, so I implemented a JavaScript solution to strip the http:// before posting the data.

这已经工作了一段时间,但遗憾的是,错误仍然是由一些较长的网址引发的。

This worked for a while, but unfortunately, the error is still being triggered by some longer url's.

我还有什么方法可以使用在发布之前清理URL以便它不会触发这样的安全模块吗?

Are there any further methods I can use to cleanse the URL before posting it so that it won't trigger a security module like this?

推荐答案

我遇到了类似的问题我该怎么做id是要求我的托管服务提供商为该特定页面添加对mod_security的排除,并且已修复。另一种方法是禁用mod_security,他们不想这样做:)

I have had a similar issue and what I did was ask my hosting provider to add an exclusion to mod_security for that specific page, and it was fixed. The alternative was to disable mod_security, which they did not want to do :)

您可能尝试的另一件事是在提交按钮上执行Javascript操作,这会执行base64编码URL,然后使用该编码值提交表单。然后,在服务器端,你解码它。

Another thing you might try is having a Javascript action on the submit buttons, which does a base64 encode of the URL, and then submits the form with that encoded value. Then, on the server side, you decode it.

希望这会有所帮助。

这篇关于使用PHP通过表单发布URL时触发错误403的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆