Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8391111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:10:28+00:00 2026-06-09T19:10:28+00:00

I wanted to handle 403 error without using server side error redirection methods(i.e. without

  • 0

I wanted to handle 403 error without using server side error redirection methods(i.e. without using .htaccess file). Sometimes server returns a 403 error message (forbidden access). So is it possible to have PHP script which handles this 403 error message?

For example, Before showing error page, I would like to obtain server status when it my specific php page runs, and without making a redirection, I would just like to display custom message in the that page.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T19:10:30+00:00Added an answer on June 9, 2026 at 7:10 pm

    Some solutions for you.

    1. Check for URL errors and make sure the actual web page is specified. Its common reason for a web site to return the 403 Forbidden error, when the URL is pointing to a directory instead of a web page. Which can be done using HttpRequest Class in PHP. You can use http_get to perform GET request. You can also Test URL here.

       <?php
       $response = http_get("URL", array("timeout"=>1), $info);
       print_r($info);
       ?>
      

    Output:

        array (
           'effective_url' => 'URL',
           'response_code' => 403,
           .
           and so on
           )
    

    What is important for you is response_code with which you can play further.

    1. Use of curl.

       function http_response($url)
       { 
           $ch = curl_init(); 
           curl_setopt($ch, CURLOPT_URL, $url); 
           curl_setopt($ch, CURLOPT_HEADER, TRUE); 
           curl_setopt($ch, CURLOPT_NOBODY, TRUE); 
           curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); 
           $head = curl_exec($ch); 
           $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); 
           curl_close($ch); 
      
           if(!$head) 
           {  
            return FALSE; 
           } 
      
           return $httpCode;
       }
      
       $errorcode = http_response("URL");    //if success 200 otherwise different
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wanted to incorporate GUMP https://github.com/Wixel/GUMP into my site for server side validation. But
I wanted to handle all internal errors gracefully, without program termination. As discussed here
I wanted to use 6 different textures on a cube, one per side, but
I wanted to use HandlerExceptionResolver to handle exceptions related to request issues such as
I wanted to implement web hooks in python. Both at server end and client
Just wanted to get the groups thoughts on how to handle configuration details of
I wanted to add an event for a textbox to handle when it loses
Now that rvm seams to handle maglev with ease I wanted to start experimenting
I want to implement a calendar app and wanted to handle recurring events, as
I wanted to write a server that a client could connect to and receive

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.