用modRewrite将php重写为html后,登录页面将不再工作

用modRewrite将php重写为html后,登录页面将不再工作,php,mod-rewrite,seo,Php,Mod Rewrite,Seo,首先我想说我是新来的,我需要一些htaccess方面的帮助。 我编写了一些mod_重写规则来重写用户配置文件,将php文件重写为html,并将php重定向到html,但现在我遇到了login.php的问题。 不允许我登录。我做错了什么?这是我的htaccess规则和login.php <IfModule mod_rewrite.c> Options +FollowSymLinks RewriteEngine on RewriteBase / RewriteCond %{REQU

首先我想说我是新来的,我需要一些htaccess方面的帮助。 我编写了一些mod_重写规则来重写用户配置文件,将php文件重写为html,并将php重定向到html,但现在我遇到了login.php的问题。 不允许我登录。我做错了什么?这是我的htaccess规则和login.php

<IfModule mod_rewrite.c>


Options +FollowSymLinks
RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9_-]+)$ profilo.php?u=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ profilo.php?u=$1

RewriteCond %{REQUEST_URI} ^/(.*)\.html$
RewriteCond %{DOCUMENT_ROOT}/%1.php -f
RewriteRule ^(.*)\.html$ $1.php [nc]



RewriteCond %{THE_REQUEST} ^[A-Z]+\s([^\s]+)\.php\s
RewriteRule .* %1.html [R=301,L]
</IfModule>
function LoginForm(){
require("inc/config.inc.php");

ob_start(); //start output buffering

session_start(); //initialize session

if(isset($_SESSION["utente_id"]))
{
    header("Location: index.html");
}

if($_SERVER["REQUEST_METHOD"] == "POST")
{
    require(MYSQL);
    $errors = array();

    //Validate the email address:
    if(!empty($_POST["username"]))
    {
        $username = mysqli_real_escape_string($database, $_POST["username"]);
    }
    else
    {
        $errors[] = "Inserisci il tuo username.";
    }

    //Validate the password:
    if(!empty($_POST["password"]))
    {
        $password = mysqli_real_escape_string($database, $_POST["password"]);
    }
    else
    {
        $errors[] = "Inserisci la tua password.";
    }

    // $query  = "SELECT active FROM users WHERE (email = '$email' AND password = SHA1('$password'))";
    // $result = mysqli_query($database, $query);

    // $shitnigga = mysqli_fetch_array($result, MYSQLI_ASSOC);
    // print_r($shitnigga);

    if(empty($errors))
    {
        $query  = "SELECT utente_id, username, utente_level FROM users 
                   WHERE (username = '$username' AND password = SHA1('$password')) 
                   AND active IS NULL";
        $result = mysqli_query($database, $query) or trigger_error("Query: $query\n<br>MySQL Error: " . mysqli_error($database));

        if(@mysqli_num_rows($result) == 1) //A match was made
        {
            //Register the values:
            $_SESSION = mysqli_fetch_array($result, MYSQLI_ASSOC);
            mysqli_free_result($result);
            mysqli_close($database);

            //Redirect the user:
            $url = BASE_URL . "panello.php";
            ob_end_clean(); //Delete the buffer.
            header("Location: $url");
            exit();
        }
        else
        {
            echo '<p class="error">Either the email address and password entered do not match or your account is not activated.</p>';
        }
    }
    else
    {
        echo '<ul class="error">';
        echo "<h3>Error(s) occured!</h3>";
        foreach($errors as $error)
        {
            echo "<li>{$error}</li>";
        }
        echo "</ul>";
    }

    mysqli_close($database);
}





echo '<form method="POST" action="login.php" name="login"  id="formID">';
echo '<ul>
<li><p class="login_p">Username</p>     
<input type="text" name="username" id="username"  size="30" class="validate[required] text-input" placeholder="username" />
</li>
<li><p class="login_p">Password</p>     
<input type="password" name="password" id="password" size="30" class="form-text" autofocus placeholder="password"/>
</li>
<li>

<input type="submit" name="login" value="login">
</li>

</ul>';

echo '</form>';

}

选项+FollowSymLinks
重新启动发动机
重写基/
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^([a-zA-Z0-9_-]+)$profilo.php?u=$1
重写规则^([a-zA-Z0-9_-]+)/$profilo.php?u=$1
重写cond%{REQUEST\u URI}^/(.*)\.html$
重写cond%{DOCUMENT_ROOT}/%1.php-f
重写规则^(.*)\.html$$1.php[nc]
重写cond%{u请求}^[A-Z]+\s([^\s]+)\.php\s
重写规则。*%1.html[R=301,L]
这是我的login.php

<IfModule mod_rewrite.c>


Options +FollowSymLinks
RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9_-]+)$ profilo.php?u=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ profilo.php?u=$1

RewriteCond %{REQUEST_URI} ^/(.*)\.html$
RewriteCond %{DOCUMENT_ROOT}/%1.php -f
RewriteRule ^(.*)\.html$ $1.php [nc]



RewriteCond %{THE_REQUEST} ^[A-Z]+\s([^\s]+)\.php\s
RewriteRule .* %1.html [R=301,L]
</IfModule>
function LoginForm(){
require("inc/config.inc.php");

ob_start(); //start output buffering

session_start(); //initialize session

if(isset($_SESSION["utente_id"]))
{
    header("Location: index.html");
}

if($_SERVER["REQUEST_METHOD"] == "POST")
{
    require(MYSQL);
    $errors = array();

    //Validate the email address:
    if(!empty($_POST["username"]))
    {
        $username = mysqli_real_escape_string($database, $_POST["username"]);
    }
    else
    {
        $errors[] = "Inserisci il tuo username.";
    }

    //Validate the password:
    if(!empty($_POST["password"]))
    {
        $password = mysqli_real_escape_string($database, $_POST["password"]);
    }
    else
    {
        $errors[] = "Inserisci la tua password.";
    }

    // $query  = "SELECT active FROM users WHERE (email = '$email' AND password = SHA1('$password'))";
    // $result = mysqli_query($database, $query);

    // $shitnigga = mysqli_fetch_array($result, MYSQLI_ASSOC);
    // print_r($shitnigga);

    if(empty($errors))
    {
        $query  = "SELECT utente_id, username, utente_level FROM users 
                   WHERE (username = '$username' AND password = SHA1('$password')) 
                   AND active IS NULL";
        $result = mysqli_query($database, $query) or trigger_error("Query: $query\n<br>MySQL Error: " . mysqli_error($database));

        if(@mysqli_num_rows($result) == 1) //A match was made
        {
            //Register the values:
            $_SESSION = mysqli_fetch_array($result, MYSQLI_ASSOC);
            mysqli_free_result($result);
            mysqli_close($database);

            //Redirect the user:
            $url = BASE_URL . "panello.php";
            ob_end_clean(); //Delete the buffer.
            header("Location: $url");
            exit();
        }
        else
        {
            echo '<p class="error">Either the email address and password entered do not match or your account is not activated.</p>';
        }
    }
    else
    {
        echo '<ul class="error">';
        echo "<h3>Error(s) occured!</h3>";
        foreach($errors as $error)
        {
            echo "<li>{$error}</li>";
        }
        echo "</ul>";
    }

    mysqli_close($database);
}





echo '<form method="POST" action="login.php" name="login"  id="formID">';
echo '<ul>
<li><p class="login_p">Username</p>     
<input type="text" name="username" id="username"  size="30" class="validate[required] text-input" placeholder="username" />
</li>
<li><p class="login_p">Password</p>     
<input type="password" name="password" id="password" size="30" class="form-text" autofocus placeholder="password"/>
</li>
<li>

<input type="submit" name="login" value="login">
</li>

</ul>';

echo '</form>';

}
函数LoginForm(){ 要求(“inc/config.inc.php”); ob_start();//开始输出缓冲 会话_start();//初始化会话 如果(isset($_会话[“utente_id”])) { 标题(“位置:index.html”); } 如果($\服务器[“请求\方法”]=“发布”) { require(MYSQL); $errors=array(); //验证电子邮件地址: 如果(!空($\u POST[“username”])) { $username=mysqli\u real\u escape\u字符串($database,$\u POST[“username”]); } 其他的 { $errors[]=“Inserisci il tuo用户名。”; } //验证密码: 如果(!空($\u POST[“password”])) { $password=mysqli\u real\u escape\u字符串($database,$\u POST[“password”]); } 其他的 { $errors[]=“Inserisci la tua密码。”; } //$query=“从用户中选择活动,其中(email='$email'和password=SHA1('$password')”; //$result=mysqli_query($database,$query); //$shitnigga=mysqli\u fetch\u数组($result,mysqli\u ASSOC); //印刷品($shitnigga); if(空($errors)) { $query=“从用户中选择用户id、用户名、用户级别 其中(用户名=“$username”和密码=SHA1(“$password”)) “活动为空”; $result=mysqli_query($database,$query)或trigger_error($query:$query\n
MySQL error:“.mysqli_error($database)); if(@mysqli\u num\u rows($result)==1)//进行了匹配 { //注册值: $\u SESSION=mysqli\u fetch\u数组($result,mysqli\u ASSOC); mysqli_免费_结果($result); mysqli_close($database); //重定向用户: $url=BASE_url.“panello.php”; ob_end_clean();//删除缓冲区。 标题(“位置:$url”); 退出(); } 其他的 { echo“

输入的电子邮件地址和密码不匹配,或者您的帐户未激活。

”; } } 其他的 { echo'
    ; echo“发生错误!”; foreach($errors作为$error) { 回声“
  • {$error}
  • ”; } 回声“
”; } mysqli_close($database); } 回声'; 回声'
  • 用户名
  • 密码
'; 回声'; }
我想重新启动服务器后,它会工作的

如果我删除这一行htaccess,它会工作,但是扩展html会在第二次重写%{the_REQUEST}^[A-Z]+\s([^\s]+)\.php\s RewriteRule.*%1.html[R=301,L]@Md.Sahadat Hossain你能帮我一下吗?修复了表单action=“login.php”上的问题htaccess会一次又一次地将我重定向到login.html…:)