Search code examples
phplaravelhostingproduction

Uploaded a s PHP site to the web, only index page works


I uploaded my site for the first time to an ipage hosting. There was no public_html folder, and the root directory is actually public so I uploaded all of my website folders to it, and gave open viewing permissions only to my public files. Now my home page is working and the rest of the isn't and I think it has something to do with the location of the files that is now different than when it was local, because of the structure of the ipage directories. The error I get is 'Page not found'.

This is an example from my route.php file:

Route::get('/', 'PagesController@index');
Route::get('store', 'StoreController@index');

(home page works, store doesn't).

Controllers example:

class PagesController extends MainController
{
public function index()
{   
    self::$data['title'] = 'Ayala & Tamar | Home Page';
    return view('content.home', self::$data);       
}


 class StoreController extends MainController
{
//Getting dynamic categories
public function index()
{ 
 self::$data['title'] = 'Ayala & Tamar | Store';
 self::$data['categories'] = Category::all()->toArray();
 return view('content.categories', self::$data);   
}

All my Laravel and PHP structure stayed the same and is in the main project directory, except for the public files which are no longer in the public folder, they are directly in the main directory.

Does anyone have an idea for a solution? Thanks!


Solution

  • Set route like this, so your route.php file look like this

    Route::controllers([
      'store' => 'StoreController'
    ]);
    
    Route::get('/', 'HomeController@index');
    

    Your controller

    class StoreController extends Controller
    {
      public function getIndex(Request $request)
      {
        self::$data['title'] = 'Ayala & Tamar | Store';
        self::$data['categories'] = Category::all()->toArray();
        return view('content.categories', self::$data);   
      }
    }