I am trying to serve my Laravel application from a Homestead machine with the following 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
I have the following routes:
Route::get('/', function () {
return view('welcome');
});
Route::get('/hello-world', function () {
return view('helloworld');
});
When I serve the website from git bash I can go to http://localhost:8000/ to view the first URL. However, if I go to http://exampleurl.test I get a No input file specified.
To access the welcome page I have to append /index.php
to the URL. I have not figured out what the URL is for the /hello-world one when run by Homestead.
How can I make sure that the welcome page is served on the URL http://exampleurl.test
and hello-world is available at http://exampleurl.test/hello-world
I fixed it the following way:
1.edited the .htaccess
file in my /public
directory with the following:
<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>
Renamed server.php
in the project root to index.php
ran vagrant reload --provision