Rewrite to public folder

2024-01-30 PHP

If you install the symphony framework or a shopware webshop for example, you have to change the routing on our web server, because the applications require, that the webroot be pointed to the '/public' folder of the project.

in my local environment, I do not like to change this, because I have to change this in my docker file or when I have the web application in a subfolder (like localhost/project1).

Add a '.htaccess' file in the root directory with the following content and it works:

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

A example

❰ back