Transfer Website in Subfolder (~/www/new_site) to Base Folder (~/www)

Silverstripe Version: 4.4.x

Question: How can I move a silverstripe server in a subdirectory to the base folder?
When I started the project, it made sense to just create the website in a subfolder in the web server. Now, the issue is I want to move the website from the subfolder to its base folder. Specifically, the root of my silverstripe project is ~/www/new_site and I want to move it to ~/www.

The reason I am doing this is so that the website can be accessed from http://<website_name> instead of https://<website_name>/new_site/test/public

This talks about just moving files from the subfolder to the base directory. But the thing is, if I move everything from ~/www/new_site/ to ~/www, that will make me access it from https://<website_name>/test. If I move everything from ~/www/new_site/test/ to ~/www, then I’m missing the .env file from ~/www/new_site.

Note I just found this thread which is the same problem I am facing, but it was never solved. Anyone have any ideas?

Depending on the server you use (in your case I assume Apache HTTP Server (httpd)) there are usually 2 different folders you should care about:

  1. Application folder (the application root, which has the "composer.json" file)
  2. Server document root (for Silverstripe CMS 4 this is the "public" folder)

The app folder (1) can be really anywhere on your host machine, as long as the server has access to it. However, there are conventions that it may be in /var/www folder.

The document root (2) is the folder your server cares about. That’s where index.php (or index.html) should be, and this one you would usually set up manually in your server configs.
There are some conventions in some server distros that it’s usually /var/www/html by default.

Now, I guess you want to fix your URL address of the application, and don’t really want to move your files on the server for the file movement sake.
A good convention would be to move your application folder (1) to /var/www/app-name, and then patch up your server virtualhost settings to point its document root (2) to /var/www/app-name/public.
You should be able to do so by updating your server configs (usually in /etc/apache2/sites-enabled/* for Debian based distros). Don’t forget to restart apache after that (apachectl restart) and update your application .env file to have a correct SS_BASE_URL.

Another option you may consider is to make a symlink from /var/www/html to /var/www/app-name/public, which would be usually picked up by the server default settings. However, this is a lazy and dirty option. You still have to make sure your server has access to /var/www/app-name folder.

1 Like

You are correct, I use an Apache HTTP Server. Though, I am willing to change the file structure of the server.

I don’t have sudo access also so the first option doesn’t work because I can’t restart apache. I’m using a shared hosting server from BlueHost. It allows ssh access but not sudo.

Also, ~/www/new_site has a composer.json but ~/www/new_site/test also has a composer.json.

How can I do this if I can change the file structure?

That really depends on the hosting provider settings. If it’s supposed to have only one application, then perhaps you could just move the app into the ~/app folder and create a symlink?

  • ln -s ~/app/public ~/www?