好友只要按照這個教程,我試了一下,它工作得很好!
https://medium.com/laravel-news/the-simple-guide-to-deploy-laravel-5-application-on-shared-hosting-1a8d0aee923e#.5lywcjmnn
順便說一句,你甚至都不需要這句話後半句
如果沒有您的服務器上已經安裝的作曲家,你可以輕鬆地搶項目目錄。
在我來說,我做了以下內容: 配售laravel項目的public_html的外面lara
文件夾
然後我有這個htaccess的它:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
和裏面的public_html我.htacess附:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^awesome
RewriteRule ^(.*)$ awesome/$1 [L]
其中awesome
是一個包含htacess(下上市)和index.php文件,圖標和robots.txt文件中的目錄:
<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]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
最後的更改是在index.php文件:
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <[email protected]>
*/
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels nice to relax.
|
*/
/* die(__DIR__); /home/{YOURHOST}/public_html/awesome */
require __DIR__.'/../../lara/bootstrap/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = require_once __DIR__.'/../../lara/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
你使用'資產() '在你的代碼中鏈接資源? (css,js,img ...) –
爲什麼你刪除.htaccess?這個文件對於路由很重要。當你沒有正確的.htaccess,那麼鏈接不會發送到Laravel index.php,所以它試圖訪問文件夾/文件,這不存在(所以你得到404) –
好的。那麼如何獲得一個新的.htaccess文件? – Chigoziri