php - This page isn??�t workinglocalhost is currently unable to handle this request. HTTP ERROR 500
This error occured when i am trying to access my admin panel of website on localhost server here is the code of my admin panel index.php
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$http_header = 'http://';
if (!empty($_SERVER['HTTPS'])) {
$http_header = 'https://';
}
$this_url = $http_header . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$this_url = str_replace('admin-panel', 'admin-cp', $this_url);
header("Location: $this_url");
exit();
?>
You can access the admin panel, from <a href="<?php echo $this_url ?>"><?php echo $this_url ?></a>
Answer
Solution:
Try testing for admin-panel
in the URL before redirecting, like this:
if (strpos($this_url, 'admin-panel') !== false)
{
$this_url = str_replace('admin-panel', 'admin-cp', $this_url);
header("Location: $this_url");
exit();
}
If str_replace('admin-panel', 'admin-cp', $this_url)
fails, $this_url
remains unchanged. If header
redirects to the same page you will get an error like "unable to handle request 500 clear your cookies", or something similar.