2017-02-12 144 views
3

我有一個Laravel5/angularJS應用程序(beeing Laravel作爲API的休息和角度爲前端)Laravel路線不工作對生產

在我的本地環境一切正常般的魅力。

但是當我上傳到主機我只能到索引頁面訪問,一切拋出的404

我的共享主機我有文件系統是這樣的。

public_html 
    laravel-backend (it has app, bootstrap, confi...etc, all laravel app) 
    laravel-frontend (it would be like the public folder of the laravel default file system) 
    .htaccess 

中的.htaccess內容:

<IfModule mod_rewrite.c> 
    RewriteEngine On 

    RewriteCond %{HTTP_HOST} anotherAppDomainAtSharedServer$ [NC] 
    RewriteCond %{REQUEST_URI} !/.*$ 
    RewriteRule ^(.*)$ /$1 [L] 

    RewriteCond %{HTTP_HOST} laravelAppDomain$ [NC] 
    RewriteCond %{REQUEST_URI} !^/laravel-frontend/.*$ 
    RewriteRule ^(.*)$ /laravel-frontend/$1 [L] 

</IfModule> 

的index.php laravel-前端內:

require __DIR__.'/../laravel-backend/bootstrap/autoload.php'; 
$app = require_once __DIR__.'/../laravel-backend/bootstrap/app.php'; 


$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); 

$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture() 
); 

$response->send(); 

$kernel->terminate($request, $response); 

和routes.php文件

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

Route::group(['prefix' => 'api/v1'], function(){ 
    Route::resource('authenticate', 'AuthenticateController', ['only' => ['index']]); 
    Route::post('authenticate', '[email protected]'); 
    .... 

因此,我說,我可以看到登錄頁面,但是當我想登錄我得到404錯誤

http://laravelAppDomain/laravel-backend/api/v1/authenticate 404 (Not Found) 
NotFoundHttpException in RouteCollection.php line 161: 

任何線索?我錯過了任何配置?

此外,我還沒有訪問配置服務器,我介意我不能編輯等文件夾主機,虛擬主機或類似我在我的本地環境。

回答

-1

我不知道如何,如果有人可以給我一個理論上的答案是值得歡迎的。

我改變了文件夾結構:

public_html 
    laravel-app 
     public 

的STANDAR laravel方式。

然後我配置指向公衆的.htaccess,並且請求開始工作。

4

假設你是一個Apache2的服務器在Unix上:

  • 運行命令sudo a2enmod rewrite
  • 確保有你的/etc/apache2/sites-available/000-default.conf的部分看起來像下面這樣。請注意,/var/www/html是apache2的根目錄默認值,您可能是/var/www/html/public或者其他類似的內容。

    <Directory /var/www/html> AllowOverride All </Directory>

  • 運行sudo service apache2 restart

  • 看看是否能工程。
+0

我看不到這些文件,我只能訪問公共html文件夾。 –

+0

我很確定其他步驟是必要的,但是你是否嘗試運行'a2enmod'命令並重新啓動服務器來檢查是否修復? – dargue3

+0

我沒有ssh acces,我只能通過c-panel進入,所以我不能運行任何控制檯命令。 –