Hello everyone, there is such a code in .htaccess that removes the php extension from the address bar, and allows you to write an address like example.com/index in the address bar instead of example.com/index.php Everything works on Ur, only there is one thing, it’s like -It conflicts with the php header function (redirect) when I remove it, the header works as it should, but with its presence, it refuses to redirect, can anyone know how to fix it, or can someone else have code that performs the same task for .htaccess?

 RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^.*$ $0.php [L,QSA] RewriteCond %{THE_REQUEST} ([^\s]*)\.php(\?[^\s]*)? RewriteRule (.*) %1 [R=301,L] 

here's the header code

 if (password_verify($pass001, $pass000) && password_verify($log001, $log000)) { echo 'Password is valid!'; session_start(); $_SESSION['shaccesforadmpanhard'] = true; header("Location: adminpan.php"); } 

    1 answer 1

    session_start and header must be applied before echo. Try this:

     if (password_verify($pass001, $pass000) && password_verify($log001, $log000)) { session_start(); $_SESSION['shaccesforadmpanhard'] = true; header("Location: adminpan.php"); echo 'Password is valid!'; } 

    It is not clear why echo is used if a redirect is used. Also, it seems to me that the Location should be / adminpan without .php

    • I tried it did not work, it's not that, without the above .htaccess code, the php script works which I wrote - hovdev
    • the problem is in the .htaccess code itself, because without it everything works with a bang - hovdev