简体   繁体   English

在URL中隐藏标题函数的PHP页面名称

[英]Hide php page name of header function in url

I'm trying to hide the php page name in url which redirects after login by header function. 我正在尝试将php页面名称隐藏在url中,该URL在通过标头函数登录后会重定向。 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 登录后事件的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 的.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? 如何隐藏使用.htaccess文件从标头功能重定向的文件? Need this help badly. 急需此帮助。 Tnx. TNX。

there is an alternative way to redirect php files and hide them 有另一种方法来重定向php文件并隐藏它们

for example http://yourwebsite.com/user/login/ 例如http://yourwebsite.com/user/login/

user part main user.php or you can change the file name 用户部分主要user.php或您可以更改文件名

firstl, in your htaccess redirect to index php firstl,在您的htaccess中重定向到索引php

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
###############  SEO     ##########################
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

in your index.php file 在您的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 !");
    }

    }

Ok got a solution. 确定了。 I changed the information in header function & placed the file corresponding to the given information in .htaccess file. 我更改了标头函数中的信息,并将与给定信息相对应的文件放置在.htaccess文件中。 Here are the codes, 这是代码,

PHP Script PHP脚本

if ($row > 0 && $row[5] == 1) {
header('Location: AdminPanel');    // Instead of adminpanel.php
}

.htaccess 的.htaccess

RewriteRule    ^AdminPanel/?$    adminpanel.php    [R,NC,L]    // Added this line.

Tnx for all your efforts btw. 顺便说一句Tnx。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM