简体   繁体   English

Apache2:允许在受限制的目录中调用ajax到.php文件

[英]Apache2: allow call of ajax to .php file in restricted directory

I have restricted directory "includes" by this code in .htaccess file in same directory 我在同一目录的.htaccess文件中通过此代码限制了目录“包含”

<Directory>
    Order Deny,allow
    Allow from 127.0.0.1
</Directory>

And I have a sub-directory "orders" that contains a PHP file. 我有一个包含PHP文件的子目录“ orders”。 This is listening ajax petitions from client. 这正在侦听来自客户端的ajax请求。 I tried to add this code to the .htaccess file to allow access from client, but it doesn't woked. 我试图将此代码添加到.htaccess文件中,以允许来自客户端的访问,但是它没有被唤醒。

<Files /orders/filter_orders_ajax.php>
    order deny,allow
    allow from all
</Files>

Here is paint screen for a better understanding. 这是油漆屏幕,用于更好地理解。
Left on the buttom u can see .htaccess of "includes" directory. 在按钮的左侧,您可以看到“ includes”目录的.htaccess。

在此处输入图片说明

Any sugestions? 有任何建议吗?

可以使用文件权限来限制需要限制的目录,而不是使用.htaccess。

You need to ditch the <Directory> containers, the nature of htaccess takes care of that for you. 您需要抛弃<Directory>容器,htaccess的性质将为您解决。 Add simple this to the htacces file in you includes directory: 将简单的代码添加到您包含目录中的htacces文件中:

Order Deny,allow
Allow from 127.0.0.1
Deny from all

Then add this to the htaccess file in your orders subdirectory: 然后将其添加到您的订单子目录中的htaccess文件中:

<Files "filter_orders_ajax.php">
  Order Deny,allow
  Allow from all
</Files>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM