简体   繁体   中英

PHP - How to Hide Ajax Directory When Requesting it in Javascript File in a MVC Project?

I'm writing a MVC project. I have two directories. First one is public. Everybody can reach this directory. It contains index, javascripts, css etc... Second one contains application files. This directory is forbidden from normal users, and ajax files are contained here(in the controllers folder). When I use ajax php files in javascript, I have to use something like "application/controllers/ajax/file.php". The problem is, I don't want to expose my directory. I want to hide it like "ajax/file.php". What can I do about it?

您也可以使用mvc服务器端(但使用symfony,laravel等php这样的php),或者至少在ajax/file.php一个路由系统,然后您的ajax调用将隐藏将执行操作的文件的真实路径。 。

ALTERNATE: You can create a function in controller and you can use route.

class A {
  function ajax() {
    // return data
  }
}

Use route and call it as http://example.com/A/ajax I hope you got it.

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