我正试图从Homestead机器上为我的Laravel应用程序提供服务,方法如下。Homestead.yaml
:
name: homestead-fontys
ip: "192.168.10.12"
memory: 2048
cpus: 2
provider: virtualbox
authorize: c:/Users/karin/.ssh/id_rsa.pub
keys:
- c:/Users/karin/.ssh/id_rsa
folders:
- map: c:/Users/karin/Documents/uni/work/develop/laravel-forum/forum/
to: /home/vagrant/code
sites:
- map: exampleurl.test
to: /home/vagrant/code/public
type: apache
php: "7.2"
databases:
- forum
features:
- mariadb: false
- ohmyzsh: false
- webdriver: false
我有以下路线。
Route::get('/', function () {
return view('welcome');
});
Route::get('/hello-world', function () {
return view('helloworld');
});
当我用git bash为网站服务时,我可以进入: http:/localhost:8000 来查看第一个URL。但是,如果我到 http:/exampleurl.test 我得到一个 No input file specified.
要访问欢迎页面,我必须在后面加上 /index.php
的URL。我一直没有搞清楚hello-world那个由家园运行时的URL是什么。
如何确保欢迎页的服务网址是 http://exampleurl.test
和hello-world可在 http:/exampleurl.testhello-world。
看起来重写规则在apache中没有正确配置,所以你需要仔细检查。
是的,你需要通过 index.php
(也就是前台控制器),所以要访问hello-world,你需要访问 http://exampleurl.test/index.php/hello-world
我是用以下方法解决的。
1.编辑了 .htaccess
档案在我 /public
的目录,并添加以下内容。
<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]
</IfModule>
重新命名 server.php
在项目的根部,以 index.php
运行 vagrant reload --provision