Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

BarretWallace's avatar

Set document root to myapp/public with .htaccess

I know that setting the document root is something that should be done inside the web server configuration (apache2 on Ubuntu in my case). On my production server, I'm doing exactly that and it works well. For each laravel app, I have a distinct virtual host configuration with the respective document root set to myapp/public

My development environment, however, is based on docker. I'm using an ubuntu/apache image and mount the respective app into /var/www/html/myapp

I'm able to modify the apache/vhost-configuration of the docker image, but it has to be the same configuration for all my php dev projects. Otherwise, I would have to build a new docker image for each combination of dev projects that a team member is working on.

The vhost-configuration for development, thus, has to be located within the app's directory, which leads me to .htaccess. This would only be used inside the docker and not be copied to the production server. All paths for assets etc. have to work within the .htaccess solution as well as within the vhost one.

Is this generally possible? If yes, how? Any help is greatly appreciated!

Barret

0 likes
0 replies

Please or to participate in this conversation.