Laravel Rest API无法在实际服务器上运行

I am trying to create a small application that uses Laravel REST api as backend and Angular for frontend.

I've managed to display json on the browser in localhost but when I uploaded to 1and1.com server, the index page works fine but api ur such as - xyz.com/public/names gives a 404 page not found error.

My Directory structure

 empdir
      empdir-backend
         laravel
      empdir-frontend
         js
         css
         index.html

Am I missing some thing.

This is my Route.php

Route::get('/', function () {
    return view('welcome');
});

Route::get('names', function () {
    $data = array(
        1 => "John",
        2 => "Mary",
        3 => "Steven"
    );

    return view('rest', $data);
 });

Route::get('names/{id}', 'NameController@showEmpDetail');
Route::resource('names', 'NameController');

Controller.php

public function index()
{
    return array(
        1 => "John",
        2 => "Mary",
        3 => "Steven"
    );

}

.htaccess

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine On

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

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

you need a .htaccess file with this in it: ` Options -MultiViews RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

`

The problem was with .htaccess file that comes with Laravel.

I removed the following line

RewriteRule ^ index.php [L]

and added

RewriteRule ^(.+)$ /index.php/$1 [L]

It worked after this.