0

I have been wondering how i can make ajax request without using the .php file extension for security purpose. for instance were i want to send request to users/main/accept.php but i want to remove .php so i can have something like users/main/accept but is not working how can i do this because i know is possible.

$(".accept_form").on("submit",function(event){
            event.preventDefault();
           var data =  $(this).children("input[type=hidden]").val();
           //alert(data);

       $.ajax({
        type:'post',
        url:'users/main/accept',
        data:{data:data},
        error:function(){
           alert("error fetching data");
       },
        success:function(response){

        }

       });
alertme
  • 61
  • 7
  • 2
    Why do you want to? – GrumpyCrouton Oct 30 '17 at 17:21
  • to avoid attacks from knowing my files because i have try editing other sites and i did not found any like .fileextension – alertme Oct 30 '17 at 17:27
  • So you want to remove the .php from the urls? Either use a PHP Framework, or https://stackoverflow.com/questions/4026021/remove-php-extension-with-htaccess – Stark Oct 30 '17 at 17:27
  • 2
    @alertme That won't stop anything. There are browser tools that allow you to see what files are being posted to very easily, if an attacker wanted to see that, they will. But it doesn't really matter that much. – GrumpyCrouton Oct 30 '17 at 17:28
  • GrumpyCrouton is on point, chrome and firefox offers that possibility without installing any extensions. And really, your question has nothing to do with preventing attacks. If you have any extension at the end of it or not, if it's accessible to the user then why would it matter, just don't put sensitive information on pages accessible by users. – Stark Oct 30 '17 at 17:32
  • 1
    Security through obscurity is never a good thing. – Adam Oct 30 '17 at 17:48

1 Answers1

0

Add following code in your htaccess file

RewriteCond %{THE_REQUEST} /users/main/accept\.php [NC]
RewriteRule ^ /users/main/accept [R=301,L,NE]
Prashant
  • 143
  • 1
  • 1
  • 7