好友只要按照这个教程,我试了一下,它工作得很好!
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