How to redirect all pages to home?

Guys how to do the same, but only if the path is example / admin, the redirect should go to the index.php file in the admin / directory

That is, if the address is example, then the redirect to index.php is in the root. And if example / admin or example / admin / task is on the index.php file, but in the admin folder

    1 answer 1

    RewriteRule ^example/admin/(.*)$ /admin/index.php [L,QSA] RewriteRule ^example/$ index.php [L,QSA] 

    In this case, when you click on the link / example / admin / and derivatives / example / admin / xxx, you will go to /admin/index.php. [L, QSA], L - means that the file htacces will no longer be read after this rule, if it fits. And QSA - that the transfer of parameters is allowed.

    • in parentheses. * - I can't even format the test normally, L - finishes reading the file if the rule matches - Boris Run
    • or rather RewriteRule ^ example / admin /(.) / / admin / index.php [L, QSA] - Boris Runs
    • Here is an example of formatting. It's simple: 4 spaces at the beginning of the line. I hope I did not kill anything in the editing process, look :) - D-side
    • but. that's the thing) thanks a lot for the help) - Boris Run
    • The answer alarmed the system as potentially poor quality, otherwise I would not find it, heh. Perhaps it should be expanded with a brief description of what the patterns above consist of. Perhaps, the minus who has come up will come to his senses, because he had to give him a whole unit (OUZHAS!) Of reputation. - D-side