通过虚拟主机托管时如何运行 Laravel 应用程序?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12551191/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 15:48:47  来源:igfitidea点击:

How to run Laravel app when hosted through virtual host?

phpapache.htaccesslaravel

提问by Kevin Gorjan

Coming from CodeIgniter, I'd like to learn Laravel. But I'm breaking my head 2 days over a (small) problem.

来自 CodeIgniter,我想学习 Laravel。但是我因为一个(小)问题而头疼2天。

When I browse to the URL "laravel.app", It shows me the folder content instead of the index-page of Laravel.

当我浏览到 URL“laravel.app”时,它向我显示文件夹内容而不是 Laravel 的索引页面。

These are my settings:

这些是我的设置:

Virtual Host:

虚拟主机:

<VirtualHost *:80>
 DocumentRoot "/Applications/MAMP/htdocs/laravel/public"
 ServerName laravel.app

 <Directory "/Applications/MAMP/htdocs/laravel/public">
  Options All
  AllowOverride All
 </Directory>
</VirtualHost>

.htaccess:

.htaccess:

<IfModule mod_rewrite.c>
 Options +FollowSymLinks
 RewriteEngine On
 Order allow,deny
 Allow from all
</IfModule>

<IfModule mod_rewrite.c>
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^(.*)$ index.php/ [L]
</IfModule>

I added "Order allow, deny" and "Allow from all", else I get a 404. What could be the problem?

我添加了“订单允许,拒绝”和“所有人都允许”,否则我会收到 404。可能是什么问题?

Regards

问候

采纳答案by William Cahill-Manley

I would verify public/index.php exists, and then try adding this line to your .htaccess file.

我会验证 public/index.php 是否存在,然后尝试将此行添加到您的 .htaccess 文件中。

DirectoryIndex index.php

You may also want to tag this with "mamp". Hope you find it!

您可能还想用“mamp”标记它。希望你能找到!

回答by Tekz

Did you check application/config/application.php for following entry?

您是否检查了 application/config/application.php 以获取以下条目?

'index' => 'index.php',

'index' => 'index.php',

unless you have mod_rewrite for clean_urls setup

除非你有用于 clean_urls 设置的 mod_rewrite