2017-01-16 173 views
3

我有一個laravel項目,它在本地機器上正常工作,我已經在家園設置了它,但是當我將項目上載到namecheap上的生產服務器時,沒有任何鏈接或路線工作,我只打開沒有樣式的索引頁面,如果我點擊任何鏈接,我會得到500錯誤。 我按照建議的步驟hereLaravel路由不生產生產服務器404錯誤

因此,我的laravel項目目錄與public_html以及我的laravel項目中的公共目錄處於同一級別。他們都在相同的目錄級別。我已經改變了index.php文件的路徑:

require __DIR__.'/mariva/bootstrap/autoload.php'; 
$app = require_once __DIR__.'/mariva/bootstrap/app.php'; 

然後,我已經改變了laravel項目目錄內的server.php:

require_once __DIR__.'../public_html/index.php'; 

權限顯然由namecheap客戶服務設置,但我仍然得到所有我的CSS和JS文件的404錯誤,以及點擊我的網頁上的一些HTML鏈接。

在視圖文件,我打電話給我的css文件是這樣的:

<!-- CSS Files --> 
    <link href="{{ asset('css/material-kit/css/bootstrap.min.css') }}" rel="stylesheet" /> 
    <link href="{{ asset('css/material-kit/css/material-kit.css') }}" rel="stylesheet"/> 
    <link href="{{ asset('css/landing-page.css') }}" rel="stylesheet"/> 

和js文件的方式:

<!-- Core JS Files --> 
<script src="{{ asset('js/landing-page/jquery.min.js') }}" type="text/javascript"></script> 
<script src="{{ asset('js/landing-page/bootstrap.min.js') }}" type="text/javascript"></script> 
<script src="{{ asset('js/landing-page/material.min.js') }}"></script> 

<!-- Control Center for Material Kit: activating the ripples, parallax effects, scripts from the example pages etc --> 
<script src="{{ asset('js/landing-page/material-kit.js') }}" type="text/javascript"></script> 

不知道我該怎麼解決呢?

我已經設法解決的CSS,而不是打開文件的JS問題更新,我錯誤地移動文件到錯誤的目錄。但是我仍然無法在頁面上獲得任何鏈接。

在我看來,我有這樣一個環節:

<a href="{{ url('/login') }}">Login</a> 

並在其上點擊時,我得到404錯誤。

+0

是您的服務器VPS?你的.htaccess工作嗎? – Buglinjo

+0

你部署在共享主機或服務器專用? –

+0

我在共享服務器上部署 – Marco

回答

0

您需要在共享主機中設置Laravel項目,這很好地解釋了here

通過全部7個步驟成功後,您的項目應該在服務器上正常工作。

而且這public_html

Options +FollowSymLinks 
RewriteEngine On 

RewriteRule^index.php [L] 

添加到您的.htacces文件希望它可以幫助

+0

我在閱讀文檔後編輯了我的問題。 – Marco

+0

您是否已將Laravel的所有公用文件夾內容複製到託管文件夾'public_html'?不要覆蓋'index.php'和'.htacess'文件。 – KuKeC

+0

我已經將公共laravel文件夾中的所有內容複製到public_html文件夾中,但.htacess文件除外。我修改了public_html文件夾中的existin.htacess文件,並添加了您建議的代碼,所以現在看起來像這樣:'''DirectoryIndex index.html index.php index.htm parking-page.html suPHP_ConfigPath /家庭/ marigxwy /的public_html 選項+的FollowSymLinks RewriteEngine敘述 在 重寫規則^的index.php [L]'''但是我仍然沒有得到任何CSS和JS鏈接打開。 – Marco

-2

該文件必須在公用文件夾。在終端

運行php artisan serve並在瀏覽器的URL http://localhost:8000/

0

選項-MultiViews

RewriteEngine On 
RewriteBase /laravel51/public/ 

#上面的變化到您的網站,即,RewriteBase /不管/公/

# Redirect Trailing Slashes... 
RewriteRule ^(.*)/$ /$1 [L,R=301] 

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

在.htaccess文件有可能改變