Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在url中隐藏标题函数的php页面名称_Php_.htaccess - Fatal编程技术网

在url中隐藏标题函数的php页面名称

在url中隐藏标题函数的php页面名称,php,.htaccess,Php,.htaccess,我试图在url中隐藏php页面名称,该url在通过头函数登录后重定向。到目前为止,我可以隐藏索引文件,但无法隐藏登录后重定向的文件。这是我的密码 登录后事件的PHP脚本 $sql_login = mysql_query("SELECT * FROM sms_people WHERE username='$username' AND password='$password'"); $row = mysql_fetch_array($sql_login); if ($row > 0 &

我试图在url中隐藏php页面名称,该url在通过头函数登录后重定向。到目前为止,我可以隐藏索引文件,但无法隐藏登录后重定向的文件。这是我的密码

登录后事件的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');
}
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [L]
RewriteRule    ^AdminPanel/?$    adminpanel.php    [R,NC,L]    // Added this line.
.htaccess

$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');
}
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [L]
RewriteRule    ^AdminPanel/?$    adminpanel.php    [R,NC,L]    // Added this line.

如何使用
.htaccess
文件隐藏从header函数重定向的文件?我非常需要这个帮助。Tnx.

有另一种方法可以重定向php文件并隐藏它们

比如说

user part main user.php或您可以更改文件名

首先,在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 !");
    }

    }

好的,我有个解决办法。我更改了header函数中的信息,并将与给定信息对应的文件放在
.htaccess
文件中。这是代码

PHP脚本

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

$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');
}
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [L]
RewriteRule    ^AdminPanel/?$    adminpanel.php    [R,NC,L]    // Added this line.

感谢您的努力。顺便说一句。

您是否正在尝试重新编写URL?我已经看到了链接,但在那里找不到我的解决方案。Tnx。