1

I have below two routes

Route::get('register', 
    array(
        'uses' =>  'Auth\Register\RegisterController@showRegistrationForm', 
        'as'   =>  'showRegistrationForm'
    )
);

Route::get('/', 
    array(
        'uses' =>  'Auth\Login\LoginController@showLoginForm', 
        'as'   =>  'showLoginForm'
    )
);

Both routes works perfectly on localhost. Then, I deployed the files on Linode server at path /var/www/html/adminapi2

I again checked above both urls. Login Url(default) works fine(http://50.116.5.82/adminapi2/public/) but url with route: showLoginForm gives 404 error(http://50.116.5.82/adminapi2/public/register)

AM I missing anything?

Pankaj
  • 9,749
  • 32
  • 139
  • 283

1 Answers1

1

It seem you are running laravel as subdirectory, to make url rewriting works, you should change public/.htacces file from:

...

RewriteRule ^ index.php [L]

...

to

...

RewriteRule ^ adminapi2/public/index.php [L]

...

Your RewriteRule should configured as subdirectory.

Hope it helps

Dharma Saputra
  • 1,524
  • 12
  • 17
  • I saw it works fine if I check route like this: http://50.116.5.82/adminapi2/public/index.php/register, I think, I am doing wrong deployment. Can you please tell where should I put the laravel code? Presently, it is deployed by making a directory called adminapi2 in /var/www/html and so the final path is /var/www/html/adminapi2 – Pankaj Jul 19 '17 at 11:08
  • Maybe yout should change the `DocumentRoot` configuration of your apache to `/var/www/html/adminapi2/public` – Dharma Saputra Jul 19 '17 at 11:10
  • no, I meant, should I put only the public files inside html and remaining files/folders inside www folder? – Pankaj Jul 19 '17 at 11:11
  • Normally when deploying laravel to server, we should change our `DocumentRoot` to `public` directory of Laravel. Laravel directory structure has been configured that only files inside `public` directory can be accessed by the browser. But if you wan't another aproach, may be you can try this way: https://medium.com/laravel-news/the-simple-guide-to-deploy-laravel-5-application-on-shared-hosting-1a8d0aee923e. – Dharma Saputra Jul 19 '17 at 11:21