Reputation: 11
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:
public_html
folder to have the same level as public_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 )
Route::get('/', function () {
return view('test');
});
"InvalidArgumentException
View [test] not found."
Route::get('/main', function () {
return view('tempview.main');
});
What did i miss? .htaccess changes? another place where i need to change the public path?
Upvotes: 1
Views: 2692
Reputation: 151
I am answering depend on your trying:
Step 1. copy index.php and .htaccess from public to public_html that means into root folder.
Step 2. modify the index.php into public_html folder
From: require __DIR__.'/../vendor/autoload.php';
To: require __DIR__.'/vendor/autoload.php';
And
From: $app = require_once __DIR__.'/../bootstrap/app.php';
To: $app = require_once __DIR__.'/bootstrap/app.php';
Upvotes: 2