i want to ask why my .htaccess in root folder does not work well.
.htaccess
RewriteEngine On
RewriteRule ^([a-zA-Z0-9]+)(/[a-zA-Z0-9/]+)?$ /$1\.php$2 [L]
RewriteCond %{THE_REQUEST} ^GET\s/*pages/.*\.php [NC]
RewriteRule ^([a-zA-Z0-9]+)(/[a-zA-Z0-9/]+)?$ /$1\.php$2 [L]
RewriteCond %{THE_REQUEST} ^GET\s/*debates/.*\.php [NC]
RewriteRule ^([a-zA-Z0-9]+)(/[a-zA-Z0-9/]+)?$ /$1\.php$2 [L]
Links in the / (main folder) are with working .php hidding, but in the subfolders like /pages/ and /debates/ the system does not recognize rewrite rule. I want to hide .php in both directories like they are hidden in the main folder.
I FIND THE SOLUTION!
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ $1.php [L,QSA]