it's really difficult to understand htaccess's work, I have this code:
#Remove slash on the end
RewriteRule ^(.*)/$ $1 [R=301]
#Don't use .php extension in URL
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ $1.php
#All the directories should be redirected to index.php
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . index [R=301]
Structure of my root folder: index.php
, .htaccess
and dir
directory with test.php
file inside.
I know that this file re-executes multiple times until the changes in URL are over, so if I'm writing mysite.ru/index/dir/
to address bar for example (I use existing index file as directory, otherwise, if I use words that aren't related to existing file names, it's works), I'm expecting 404 page (Slash removes, dir.php doesn't exist, index/dir doesn't exist, file executes again, URL didn't changed and it's over), but I'm getting 500 error and 10 redirects in error.log file. Something wrong with .htacess
file, and I can't understang what.
question from:
https://stackoverflow.com/questions/65648004/htaccess-file-how-do-these-redirects-work 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…