Page 1 of 1

VestaCP and Laravel

Posted: Mon Apr 02, 2018 3:01 pm
by fedekrum
Hi all.
Suppose I have a site called utilities.mydomain.com.

Inside there, I want to make several laravel projects in each folder.
eg.
utilities.mydomain.com/tool1
utilities.mydomain.com/tool2
utilities.mydomain.com/toolx

How can I make all these work with simply adding .htaccess file/s somewhere in utilities.mydomain.com or any other place?

Points.
a) I don't want to split the Laravel folders as I saw in other tutorials. Each folder must be a pure installed Laravel project.
b) I can make "utilities.mydomain.com/tool1/public" work with no problem with simply adding "composer create-project laravel/laravel toolz" inside the public_html folder, but I want to get rid of the "public/" term in the URL.

Thanks, Federico

Re: VestaCP and Laravel

Posted: Sun Apr 08, 2018 9:24 am
by tjebbeke
You can do this with htaccess files.

utilities.mydomain.com/public_html/toolx/.htaccess

Code: Select all

<IfModule mod_rewrite.c>
	RewriteEngine on
    RewriteBase /toolx
	RewriteCond %{REQUEST_URI} !^toolx/public
	RewriteRule ^(.*)$ /toolx/public/$1 [L]
</IfModule>
utilities.mydomain.com/public_html/toolx/public/.htaccess

Code: Select all

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>
    
    <IfModule mod_headers.c>
      <FilesMatch ".(js|css|xml|gz|html)$">
        Header append Vary: Accept-Encoding
      </FilesMatch>
    </IfModule>

    RewriteEngine On
    RewriteBase /toolx

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /toolx/$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

Re: VestaCP and Laravel

Posted: Tue May 29, 2018 8:13 am
by k26
just facing the same problem as @fedekrum and discovered your solution @tjebbeke , but after some tests it does not run for me ....
when we call the toolx url I have a message "Sorry, the page you are looking for could not be found"
and if I add index.php then I can continue but all the next links will display toolx/public/rest_of_url
Maybe because I run L5.6 ?