【发布时间】:2017-02-16 08:47:55
【问题描述】:
我有一个 Laravel5/angularJS 应用程序(将 Laravel 作为前端的 api rest 和 angular)
在我当地的环境中,一切都像魅力一样。
但是当我上传到主机时,我只能访问索引页面,其他所有内容都会抛出 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>
在 laravel-frontend 中的 index.php:
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', 'AuthenticateController@authenticate');
....
所以,正如我所说,我可以看到登录页面,但是当我想登录时,我得到 404 错误
http://laravelAppDomain/laravel-backend/api/v1/authenticate 404 (Not Found)
NotFoundHttpException in RouteCollection.php line 161:
有什么线索吗?有什么我想念的配置吗?
此外,我无法访问配置服务器,我介意我无法像在本地环境中那样编辑 etc 文件夹主机、虚拟主机或类似内容。
【问题讨论】:
标签: php angularjs .htaccess laravel shared-hosting