3 Ответа

  1. VolSu VolSu 11 Августа 2021 (ред.)

    Try one of the following options:

    First:

    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_URI} !^/public/
    RewriteRule (.*)  /public/$1 [L]

    Second:

    RewriteEngine on
    RewriteRule ^$  public/ [L]
    RewriteRule ((?s).*)  public/$1 [L]

    The third:

    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^public
    RewriteRule ^(.*)$  public/$1 [L]

    But it's better to set at the Apache level

  1. Evg Evg 11 Августа 2021 (ред.)

    I tried adding a file .htaccess with content:

    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^/public/
    RewriteRule ^(.*)$ public/$1 [L]

    .htaccess

    And it seems to work for me. I did not touch the original file (.htaccess) in the public folder.

    However, I don't really like this method from a security point of view.

    The best solution is to configure the root directory using the method of the server itself, the Apache configuration, for example.

    As I recall, this was a common question. Many CMS use public folder, for example: laravel. There should be solutions on the Internet how to change the server configuration.

    https://libarea.com/ru/web-server-configuration/

    1. wfsdaj wfsdaj 11 Августа 2021

      Thank you very much. The problem has been solved.👌