简体   繁体   中英

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

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

And I have a sub-directory "orders" that contains a PHP file. This is listening ajax petitions from client. I tried to add this code to the .htaccess file to allow access from client, but it doesn't woked.

<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.

在此处输入图片说明

Any sugestions?

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

You need to ditch the <Directory> containers, the nature of htaccess takes care of that for you. Add simple this to the htacces file in you includes directory:

Order Deny,allow
Allow from 127.0.0.1
Deny from all

Then add this to the htaccess file in your orders subdirectory:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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