I want my user to redirected to page where user clicked login so i added following code to config file so that each and ever file has access to redirect code
config.php
if (isset($_SERVER['HTTP_REFERER']) && basename($_SERVER['HTTP_REFERER']) != basename($_SERVER['PHP_SELF'])) {
$_SESSION['redirect_url'] = $_SERVER['HTTP_REFERER'];
}
So that when ever i need a redirect i can simple call like bellow
header('location:' . $_SESSION['redirect_url']);
exit();
and when i try above code i get error showing
ERR_TOO_MANY_REDIRECTS
i even tried echo $_SESSION['redirect_url'] and it showed a valid requested URL
But it doesn't redirected. Can some one help me what wrong im doing.
and here is
.htaccess
RewriteEngine On
# browser requests PHP
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\ ]+)\.php
RewriteRule ^/?(.*)\.php$ /$1 [L,R=301]
# check to see if the request is for a PHP file:
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^/?(.*)$ /$1.php [L]