允许AJAX访问浏览器通常无法访问的脚本 [英] Allowing AJAX to access scripts that are not normally accessible to the browser
问题描述
这是我的第五个帖子,非常好,请加糖甜点。
在我的网页目录中,我有一个.htacces文件,拒绝所有查看我的文件PHP文件。然而,文件可以由服务器和其他PHP文件运行。
现在,我有几个XhttpRequest,由JavaScript(JS)运行。问题是,当JS试图请求受保护的PHP文件时,请求将返回禁止等。
如何让JS无需运行此类文件取消对PHP的保护,这可能吗?
我知道这与htacccess问题接壤,但我认为AJAX人是我知道这个。
Hi, this is my fifth thread, so pretty please, be sugar sweet.
In my web directory I a .htacces file that deny all to view my PHP files. The files can however be run by the server and other PHP files.
Now, I have several XhttpRequest, run by JavaScript (JS). The problem is that when JS is trying to request a PHP file that is protected the request will return "forbidden etc.".
How can I allow JS to run such files without removing the protection from the PHP, is this possible?
I know that this borders to a htacccess question, but I figured that "AJAX people" would know this.
推荐答案
你可以在AJAX GET或POST请求中传递一个允许的用户名和密码。
you can pass a permitted username and password in an AJAX GET or POST request.
您可以在AJAX GET或POST请求中传递允许的用户名和密码。
you can pass a permitted username and password in an AJAX GET or POST request.
我该怎么做? *开始使用Google *
Eh,一些澄清:我的意思是,我知道如何使用POST和东西,我的意思是我将如何设置密码,只有JS会了解并检查它...?反对htaccess密码?或者我是否为相关的PHP文件设置了某种形式的安全许可?
How would I do that? *Starting to Google*
Eh, some clarification: I mean, I know how to use POST and stuff, what I mean is how would I set up a password, that only JS would know about and check it against...? Against htaccess password? Or do I set up some form of security clearance for the PHP file in question?
您可能需要更改php.ini文件。添加.js扩展名。
我希望这能引导你至少朝着正确的方向前进。
对不起我希望我知道该怎么做,但至少我很好;)
You may have to alter the php.ini file. Add .js extension.
I hope this steers you in at least the right direction.
Sorry I wish I knew exactly what to do, but hey at least I was nice ;)
这篇关于允许AJAX访问浏览器通常无法访问的脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!