Search code examples
phpajaxhttpforbiddenhandler

403 Forbiddenh in Client's Server


In my application when i sending mail forbodden error message is displayed This is my ajax code

$.ajax({  
                    type: "POST",  
                    url: "http://www.ryuneo-clients.co.uk/houndzabout/process.php/"+x+"/"+y,
                    success: function(msg){
                    if(msg == 0)
                    {
                        alert("Your Request Is Send!");
                    }else{
                        alert("Your Request Is Failed!");
                    }
                    $("#txtname").val("Your Name");
                    $("#txtphone").val("Your Phone Number");
                    }
                });

This is the process.php page

<?php
    $uri = $_SERVER['REQUEST_URI'];
    $pieces = explode("/", $uri);
    $name = $pieces[3];
    $phone = $pieces[4];

    $nam11 =  urldecode($name);

    /*$to = "[email protected]";*/
    $to = "[email protected]";
    $subject = "New Request Come !";
    $message = '<div style="background-color: #EEEEEE;border-bottom: 1px solid #DCDCDC;padding: 10px 0 20px;width: 400px;"> 
<div style="width:400px;">

<div style="width:400px;background-color:#eeeeee;padding: 10px 0 20px;border-bottom:1px solid #dcdcdc;">
<div style="width:300px; text-align:center;color:#666666;margin-left:20px;font-size:12px;font-weight:bold;">
Now you got a new request from :
</div>
</div> <!--end of div_form_main-->
<div style="width:400px;background-color:#eeeeee;padding: 10px 0 20px;border-bottom:1px solid #dcdcdc;">
<div style="float:left;width:150px;color:#666666;margin-left:20px;font-size:12px;font-weight:bold;"> Name:</div>
<div style="float:left;width:auto;color:#000000;font-size:12px;font-weight:bold;">'.$nam11.'</div>
</div> <!--end of div_form_main-->
<!--end of div_form_main-->
<div style="width:400px;background-color:#eeeeee;padding: 10px 0 20px;border-bottom:1px solid #dcdcdc;">
<div style="float:left;width:150px;color:#666666;margin-left:20px;font-size:12px;font-weight:bold;"> Phone Number:</div>
<div style="float:left;width:auto;color:#000000;font-size:12px;font-weight:bold;">'.$phone.'</div></div> <!--end of div_form_main-->
</div> <!--end of div_password_main-->';
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
    $headers .="Content-Transfer-Encoding: 8bit";
    if(!mail($to, $subject, $message, $headers))
    {
        echo 1;
    }
    else
    {
        echo 0;
    }
    //die();
?>

when i sending mail

"NetworkError: 403 Forbidden - http://www.ryuneo-clients.co.uk/houndzabout/process.php/fvgh/111-111-11111111"

is displayed in firebug.When i taking the url in new window this message come

Forbidden

You don't have permission to access /houndzabout/process.php/fvgh/111-111-11111111 on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Solution

  • Unless you have a .htaccess file specifying rewrite rules, your linux server will interpret that as a path. So instead of looking for

    file process.php in folder .../houndzabout and passing it "fvgh" and "111-111-11111111"

    The server is looking for

    file 111-111-11111111 in folder .../hound/process.php/fvgh and passing it nothing

    (note that folder names with periods are valid)

    It's doing this because you're separating your filename (houndzabout/process.php) and arguments with a forward slash.

    Traditionally, "GET" parameters are passed following a question mark (?) and separated by ampersands (&).

    In that case, your url line in your javascript should look something like:

    url: "http://www.ryuneo-clients.co.uk/houndzabout/process.php?"+x+"&"+y