我正在尝试隐藏url中的php页面名称,该页面名称在登录后通过header函数重定向。到目前为止,我可以隐藏索引文件,但无法隐藏登录后重定向的文件。这是我的代码,
登录后事件的PHP脚本
$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]
如何使用.htaccess
文件隐藏从标题功能重定向的文件?非常需要这个帮助。 TNX。
答案 0 :(得分:0)
有一种替代方法可以重定向php文件并隐藏它们
例如,http://yourwebsite.com/user/login/
用户部分主用户.php或您可以更改文件名
firstl,在你的htaccess重定向到索引php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
############### SEO ##########################
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
index.php文件中的
$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 !");
}
}
答案 1 :(得分:0)
好的,有一个解决方案。我更改了标题功能和信息中的信息。将对应于给定信息的文件放在.htaccess
文件中。这是代码,
PHP脚本
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为你所有的努力顺便说一句。