Javascript无法访问根目录下的php脚本
我的文件夹结构:Javascript无法访问根目录下的php脚本,php,ajax,directory,Php,Ajax,Directory,我的文件夹结构: /public /css /fonts /images /js index.php /resources /configs /library /scripts /templates 我的问题是validate.js(位于/js中)无法访问validate.php(位于/scripts中) 谢谢 更新,以下是错误消息: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&
/public
/css
/fonts
/images
/js
index.php
/resources
/configs
/library
/scripts
/templates
我的问题是validate.js(位于/js中)无法访问validate.php(位于/scripts中)
谢谢
更新,以下是错误消息:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /resources/scripts/validate.php was not found on this server.</p>
<p>Additionally, a 404 Not Found
error was encountered while trying to use an ErrorDocument to handle the request.</p>
<hr>
<address>Apache/2.4.3 (Win32) OpenSSL/1.0.1c PHP/5.4.7 Server at localhost Port 80</address>
</body></html>
404找不到
找不到
在此服务器上找不到请求的URL/resources/scripts/validate.php
此外,未找到404
尝试使用ErrorDocument处理请求时遇到错误
本地主机端口80上的Apache/2.4.3(Win32)OpenSSL/1.0.1c PHP/5.4.7服务器
试试看
php脚本应该能够访问它 创造 /public/cgi/myvalidate.php 与
或者将validate.php放在一个可以公开访问的位置。我的问题中的拼写错误。刚刚更新。url前面没有正斜杠。同样的问题。无法访问。使用validate.js的文件的路径是什么?路径是localhost/public/js/validate.jsI可以将validate.php放入/public,但目标是确保没有人可以访问/scripts中的文件。@TimNguyenBSM我假设目标是这样的,但是,如果需要validate.php来实现使站点正常工作的目标,那么就存在相互冲突的目标。考虑到这些目标,我只会在ajax可以访问的位置使用php文件中的include。@TimNguyenBSM另一个选项是创建一个新的validate.php,但这完全违背了在脚本中使用validate.php的目的。@TimNguyenBSM注意,我已经更新了文件名,以便显示validate.php在脚本中,myvalidate.php在脚本中在cgi中,没有人能看到资源目录中的内容,因为它们不是公共的,所以没有人能看到代码。但是,设置私有目录并不是解决web安全问题的万灵丹。PHP仍然可以访问它。因此,您需要防止任何PHP代码嵌入到用户输入中,并防止用户在可以执行它们的目录中创建任何PHP文件。
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /resources/scripts/validate.php was not found on this server.</p>
<p>Additionally, a 404 Not Found
error was encountered while trying to use an ErrorDocument to handle the request.</p>
<hr>
<address>Apache/2.4.3 (Win32) OpenSSL/1.0.1c PHP/5.4.7 Server at localhost Port 80</address>
</body></html>
$.ajax( {
type: "POST",
url: "../resources/scripts/validate.php",
$.ajax( {
type: "POST",
url: "../../resources/scripts/validate.php",
<?php include '../../resources/scripts/validate.php'; ?>
$.ajax( {
type: "POST",
url: "cgi/myvalidate.php",