Answer the question
In order to leave comments, you need to log in
How to set up .htacces?
Hello!
There is a folder with the project, unfortunately there is no way to move php files (for example, cron jobs, etc.) outside the public directory.
In the folder itself, the directory intended for public access is called "public".
In a normal, regular situation, users will have pages with uri like " /public/my_profile " or " /public/about ", etc.
I can't figure out how to make it so that if someone tries to go to the root (at the address " / " or "/cron/my_cron_task.php"), redirection to the "/public" folder will work.
I think that the easiest way to implement this is through .htaccess, but how?
I would be grateful for any hints, because until now all my attempts have led to a cyclic redirect.
Answer the question
In order to leave comments, you need to log in
Use RewriteEngine in .htaccess in site root with RewriteCond defined
Something like this
RewriteEngine on
RewriteCond %{REQUEST_URI} !/public/
RewriteRule ^(.*)$ site.ru/public/$1 [L,R=301]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question