Laravel路线不工作对生产
问题描述:
我有一个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:
任何线索?我错过了任何配置?
此外,我还没有访问配置服务器,我介意我不能编辑等文件夹主机,虚拟主机或类似我在我的本地环境。
答
我不知道如何,如果有人可以给我一个理论上的答案是值得欢迎的。
我改变了文件夹结构:
public_html
laravel-app
public
的STANDAR laravel方式。
然后我配置指向公众的.htaccess,并且请求开始工作。
答
假设你是一个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
- 看看是否能工程。
我看不到这些文件,我只能访问公共html文件夹。 –
我很确定其他步骤是必要的,但是你是否尝试运行'a2enmod'命令并重新启动服务器来检查是否修复? – dargue3
我没有ssh acces,我只能通过c-panel进入,所以我不能运行任何控制台命令。 –