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

pio.skro@gmail.com's avatar

Problem with subfolder and git repository

I have prepared basic application in laravel and I my repository is located on Github.

My directories tree is typical:

└── laravel-myapp
 │   ├── .git
 │   ├── app
 │   ├── bootstrap
 │   ├── config
 │   ├── database
 │   ├── public
 │   ├── resources
 │   ├── routes
     └── etc...

But in production server I had to use a subdirectory for my app . My tree at production server (hosting) now looks like:

├── laravel-myapp
│   ├── .git
│   ├── app
│   ├── bootstrap
│   ├── config
│   ├── database
│   ├── resources
│   ├── routes
│   └── etc....
└── public_html
│   ├── othersite1
│   ├── othersite2
│   ├── othersite3
    └── myapp     # it's my folder /public 

I would like to use Git to manage myapp but there is a problem. If I move /public folder outside project folder monitored by git, I cannot manage the repository. Have you got any idea how to solve the problem?

0 likes
3 replies
calder12's avatar
calder12
Best Answer
Level 3

Symlink to the public folder don't actually move it.

Create the git repo as normal then in the console

ln -s  /path/to/public /path/to/symlink

So in your case

ln -s /public /public_html/myapp

*Note - you may have to append those paths depending on your host. Usually it's something like /home/whatever your account user is/

1 like
pio.skro@gmail.com's avatar

Thx. But now I have problem with routes. I suppose that I need to change something in .htaccess. How to fix it?

pio.skro@gmail.com's avatar

Done.

It public_html I need to set .htaccess

<IfModule mod_rewrite.c>
  Options -MultiViews
  RewriteEngine On
  RewriteBase ../laravel
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*?)$ myapp/ [L]
</IfModule>
1 like

Please or to participate in this conversation.