I'm trying to hide the php page name in url which redirects after login by header function. So far I can hide the index file but can't hide the file which redirects after login. Here are my codes,
PHP script for after login events
$sql_login = mysql_query("SELECT * FROM sms_people WHERE username='$username' AND password='$password'");
$row = mysql_fetch_array($sql_login);
if ($row > 0 && $row[5] == 1) {
header('Location: adminpanel.php');
}
.htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [L]
How can I hide the files which redirects from header function by using .htaccess
file? Need this help badly. Tnx.
there is an alternative way to redirect php files and hide them
for example http://yourwebsite.com/user/login/
user part main user.php or you can change the file name
firstl, in your htaccess redirect to index php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
############### SEO ##########################
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
in your index.php file
$rootfolder="parts"
if(isset($_GET["url"])){
$part= explode("/", $_GET["url"]);
if(isset($part[0]))
$controller = ''.strtolower($part[0]).'';
if(isset($parca[1]))
$method = ''.strtolower($part[1]).'';
if(isset($parca[2]))
$id = ''.$part[2].'';
if( file_exists($rootfolder."/".$controller.php))
{
//you can call the file if it is exits
requre_once $rootfolder."/".$controller.php;
}else{
die("404 not found !");
}
}
Ok got a solution. I changed the information in header function & placed the file corresponding to the given information in .htaccess
file. Here are the codes,
PHP Script
if ($row > 0 && $row[5] == 1) {
header('Location: AdminPanel'); // Instead of adminpanel.php
}
.htaccess
RewriteRule ^AdminPanel/?$ adminpanel.php [R,NC,L] // Added this line.
Tnx for all your efforts btw.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.