Page 1 of 1

[SOLVED] How to change the web root folder?

Posted: Tue Jul 15, 2014 11:37 pm
by openyk
VestaCP comes with the default web folder as /home/admin/web/default.domain/public_html

How can I change the web folder to instead be /home/admin/web/default.domain/public_html/some_folder ?

Specifically, I have a symlink to the project folder right now: ...public_html/project_folder_symlink
And I would like to browse to my project with http://IPADDRESS instead of having to go to http://IPADDRESS/project_folder every time.

I know the answer lies somewhere in /etc/apache2/ but I've explored a bit and I just do not know exactly where to make the change.

Solution using .htaccess file:

This solution may have path to file issues, I prefer the solution below with the apache configuration.
Add a .htaccess file to the /public_html/ folder and add the rewrite code:

Code: Select all

# Example with domain name
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain-name.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.domain-name.com$
RewriteCond %{REQUEST_URI} !folder/
RewriteRule (.*) /folder/$1 [L]

Code: Select all

# Example with IP address
RewriteEngine on
RewriteCond %{HTTP_HOST} ^123.456.78.910$ [NC,OR]
RewriteCond %{HTTP_HOST} ^123.456.78.910$
RewriteCond %{REQUEST_URI} !folder/
RewriteRule (.*) /folder/$1 [L]
Solution with apache configuration file:

For quick reference: vim is a command line text editor, press i to go into insert mode, esc to cancel insert mode, :w to save, and :exit to exit.

Code: Select all

# Open web configuration file
vim /home/admin/conf/web/apache2.conf

# Add the upload folder to the lines with /public_html/
...
DocumentRoot /home/admin/web/default.domain/public_html/upload/
...
<Directory /home/admin/web/default.domain/public_html/upload>
...

# Restart apache server
apache2ctl restart

Re: [SOLVED] How to change the web root folder?

Posted: Mon May 02, 2016 12:14 pm
by EdnaHall
I have a symlink to the project folder right now: ...public_html/project_folder_symlink????



best image resizer