Answer the question
In order to leave comments, you need to log in
How to access files in a folder of the same name?
I have an admin folder and routing works in it. I want to make a request like https://site.ru/admin/method , but I keep getting an error because php is accessing the folder and not my file.
Here is the code I wrote in htaccess:
RewriteRule ^admin/(.*)$ /admin/run.php?request=$1 [QSA]
Answer the question
In order to leave comments, you need to log in
How mod_rewrite actually works
It's important to understand that changing a query doesn't end with the last RewriteRule. After the last RewriteRule has fired, mod_rewrite looks to see if the request has changed or not. If the request has changed, its processing starts again from the beginning of .htaccess.
The address admin/run.php
successfully matches the pattern ^admin/(.*)$
and an infinite loop occurs.
After the LimitInternalRecursion is exhausted, the request processing fails with a 500 error. It is
enough to add an exception foradmin/run.php
RewriteCond %{REQUEST_URI} !^/admin/run\.php
RewriteRule ^admin/(.*)$ /admin/run.php?request=$1 [QSA,L]
RewriteCond $1 !^run\.php
RewriteRule ^admin/(.*)$ /admin/run.php?request=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^admin/(.*)$ /admin/run.php?request=$1 [QSA,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^admin/(.*)$ /admin/run.php?request=$1 [QSA,L]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question