简体   繁体   中英

Jquery ajax exposes php file

I have the following code

$.ajax({
    type:'GET',
    url:"processes/get_user_menu.php",
    success: function(output) {
        $("#likes").html(output);
    }
});

I want to know if there is another way to do this so that the php file location is not exposed?

There is absolutely nothing you can do to stop from exposing the requested php file. Any browser of any kind has the ability to record ajax request URLs, so a user can easily see what URL is being requested. Additionally, there is nothing to prevent any user agent from setting the HTTP_X_REQUESTED_WITH header to whatever it wants. Don't be prepared to expose a URL to the client side unless you can do so without restriction.

Depending on what you use, you can hide your .php extension and use folder-style of address, with or without ending slash, but that's about it. Read this on php.net (or use your frameworks utilities, if you're using a framework)

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