Laravel requires that you set your web root to the "public" folder. So in apache or whatever webserver you are using, you need to set it correctly, such as:
DocumentRoot /my/webserver/files/wedding/public
It should then work as you expect.
I seem to have the same problem, changing the document root didn't solve anything I'm afraid. :(
I have modified my 000-default.conf to point to wedding/public for the DocumentRoot (and restarted apache2). Similar to before browsing to http://192.168.1.28 now returns 'root' and http://192.168.1.28/test still returns the 404.
Would what you suggest not mean that you can only run one laravel site on your webserver?
Stephen
My only other guess is that mod rewrite is not enabled, or your security is not allowing laravel's htaccess. On debian based distro's (debian, mint, ubuntu, e.c.t.) i believe theres a helper so you can just do:
# a2enmod rewrite
# service apache2 restart
if you dont have that command available, just do a quick google for "enable mod_rewrite on <insert your operating system here>" and you should get some info on doing that.
You will also need to ensure that the htaccess file is allowed to override your virtualhost config (or put the rewrite code in the config directly). To do this, you will need AllowOverride All
in your vhost, so it should look something like this:
<VirtualHost *:80>
... Some config line like docroot and servername ...
<Directory /some/path/to/your/app>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
The important option there is AllowOverride
. Obviously after any changes to apache config, you need to restart the apache service for them to take effect.
Leydar, whilst it may be possible to get laravel working in subfolders (bit of extra code for subfolder discovery, potentially have to extend the default router and use your own, or possibly just create a route group prefix that matches your subfolder/public patten), hell it may even support it out of the box. But Laravel isn't really geared for that setup.
Laravel follows the best practice of hiding the logic (PHP) behind the docroot, so that it is not publicly accessible. So the only things that you can access via the URL, are things in the public folder. By using subfolders, you are exposing the PHP to the public, and making it so that you always have to prefix teh URL with the subfolder name and "public".
Subfolders are an archaic structural pattern and its easier to just stop using them. There's a bunch of ways of developing multiple websites, without using subfolders. The two most common methods are:
Create fake domain names, and map them to your webserver ip (127.0.0.1 if developing locally) in your hosts file (takes all of 10 seconds per domain, plus a minute to google if you dont know what im on about). I commonly use "local.projectname.com", but you could use anything you like, i know one guy that used PHP to generate a huge list of domains in the pattern of "www.project<number>.com", then dumped them into his hosts file... i dont really recommend this, but hey, he's got about 20 years of free fake domains to use i guess.
VM's are becoming widely used for development machines. You can use Laravel's own homestead, where you map your local dev files to a folder inside the VM, and let the VM manage all the database/webserver stuff. The advantage with this model, is your VM will have a dedicated local IP, so even if you booted up 3 VM's each would have a different local IP so all 3 projects remain accessible by IP without the need for subfolders.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community