Answer the question
In order to leave comments, you need to log in
How to redirect all requests from a subdirectory or non-existent directory to index.php?
I need all requests to existing and non -existing directories/subdirectories and site files to be redirected to basic/api/index.php .
When I write , Hello Worldtest-site.com/basic/api //или api/index.php
opens in basic/api/index.php as I need.
BUT when I enter the following links:
http://test-site.com/basic/api/src/
http://test-site.com/basic/api/src/db/
http://test-site.com/basic/api/src/db/dbconnect.php
http://test-site.com/basic/api/src/app/
http://test-site.com/basic/api/src/app/routes.php
http://test-site.com/basic/api/src/bootstrap/
http://test-site.com/basic/api/src/bootstrap/app.php
http://test-site.com/basic/api/non-existent-folder/ //несуществующая директория
http://test-site.com/basic/api/non-existent-file.php //несуществующий файл
RewriteEngine On
RewriteBase /basic/
RewriteRule ^(.*)$ api/index.php
Answer the question
In order to leave comments, you need to log in
First, you need to remove all files, except for index.php and statics, outside http (a couple of levels higher).
Secondly, your regular ^(.*)/
expression only works on paths that end in a slash. Figure out for yourself what needs to be fixed.
And also you have a regular season that allows you to do this
api/index.phpapi/index.phpapi/index.php
Which, as you understand, does not add health to it
RewriteCond %{REQUEST_FILENAME} !/api/index\.php
RewriteRule ^(.*)$ api/index.php
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question