.htaccess redirect root to subfolder

I want mod_rewrite to redirect all requests to non-existent files and folders and all requests to the main folder ("root") to a subfolder. So I installed it like this:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC,OR]
RewriteCond %{REQUEST_URI} / [NC]
RewriteRule ^(.*)$ /my/subfolder/$1 [L,QSA]

Unfortunately, this will not work: if I request example.com/public/, it redirects the script to my processing (therefore redirecting to my / subfolder / index.php? App = public), although there is a “public” folder, Please note that the request domain.com/ correctly redirects to my / subfolder / index.php

Why is this?

+3
source share
1 answer

, , uri, / , . :

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d [OR]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*)$ /my/subfolder/$1 [L,QSA]

, [NC] , - , "No Case" .

, .

+7

Source: https://habr.com/ru/post/1733796/


All Articles