stop direct access (.htaccess) and allow ajax request to subfolder

后端 未结 5 789
情书的邮戳
情书的邮戳 2020-12-20 01:42

I am trying to stop direct access to a subdirectories and the php files within subdirectories. I\'ve added the following code below to the .htaccess file within the subdirec

5条回答
  •  太阳男子
    2020-12-20 02:31

    I would put apache directives aside, and -perhaps- focus on a php-based solution:

    1. Make sure your file containing the jquery ajax call has a ".php" extension. (of course inside that file, all jquery must be contained within tags.

    2. Inside your jquery function just before the ajax call, type that:

      (php tags run even if they are contained in "script" tags)

    3. Open your ajax (php) file and at the very top type this:

    
    

    ... and you are Done!

    P.S. Naturally, you may (or better: should) rename the sessions and give them different or more complex values, but I was just trying to point out the basic idea... Happy coding!

提交回复
热议问题