I have read through a thread on [Laracasts thread] (https://laracasts.com/discuss/channels/general-discussion/where-do-you-set-public-directory-laravel-5?page=2) but not sure of the current right solution especially for Laravel 5.5 ? (note: i do not have access to change any config server side apart from selecting which Php version to use - and a handful ssh commands [with limited directories i can access] ).
My case: using shared hosting, so my public directory is
/home/{mycomputer generated user}/public_html/
Initially I uploaded Laravel directory into public_html folder . The system worked with the quirks of having the URL www.mydomain.xyz/public/
as the URL to root.
Then I tried this approach of modifying the path:
- Moved all files out of the
public_html
folder to have the same level aspublic_html
folder.
So the folders (in my previously laravel folder) reside here:
/home/{mycomputer generated user}/
Copied the content of
/public
into/public_html
Edited the
index.php
content of/public_html
FROM:
require __DIR__.'/../vendor/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';
TO:
require '/home/{my user}/vendor/autoload.php';
$app = require_once '/home/{my user}/bootstrap/app.php';
And now my main page loaded fine (welcome view) as stated in my web.php route file
Route::get('/', function () {
return view('welcome');
});
===================================================================
MY ISSUE:
However, any other routes would fail
"Not Found
The requested URL /{legitimate route}
was not found on this server"
Any other steps that i needed to do?
I tried: 1. loading a simple jpg file stored in public_html folder, and that worked fine (mydomain.xyz/test.jpg )
- changed the route for root to return invalid view, that threw a Laravel error
Route::get('/', function () {
return view('test');
});
"InvalidArgumentException
View [test] not found."
- Tried using closures (instead of using controllers) to return a legit view - did not work
Route::get('/main', function () {
return view('tempview.main');
});
What did i miss? .htaccess changes? another place where i need to change the public path?