Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

linuxoid's avatar

404 Not Found error on local install

These are the steps and configs I've done so far to get Laravel going on my local openSUSE Linux machine:

  • new folder in ~/home/linuxoid/Develop/www/laravel
  • :~/Develop/www/laravel>composer create-project --prefer-dist laravel/laravel blog
  • :~/Develop/www/laravel/blog>php artisan serve
  • checked in Firefox: localhost:8000 - see the Laravel default page - all is OK
  • added the following to /etc/apache2/httpd.conf:
<Directory "/home/linuxoid/Develop/www">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>
  • added new file local.conf in /etc/apache2/vhosts.d with:
<VirtualHost *:80>
    ServerAdmin localhost
    DocumentRoot /srv/www/htdocs/
    ServerName localhost
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin linuxoid
    DocumentRoot /home/linuxoid/Develop/www/
    ServerName linuxoid.dev
    ServerAlias linuxoid
     
    <Directory /home/linuxoid/Develop/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        RewriteEngine On
        Require all granted
    </Directory>
</VirtualHost>
  • added this in /etc/hosts:
127.0.0.1       linuxoid.dev    linuxoid
  • restarted the server
  • added an .htaccess to ~/Develop/www/laravel/blog with:
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /laravel/blog
    RewriteCond %{REQUEST_URI} !^public
    RewriteRule ^(.*)$ public/ [L]
</IfModule>

... and the problem is when I go to http://linuxoid/laravel/blog I get a 404 | Not Found error! If I go directly to the public folder, I get the Laravel default page.

How can I set up the local virtual host to get to the Laravel's public folder where http://linuxoid/laravel/blog should be the site's base url? What am I missing or doing wrong?

Thank you.

0 likes
13 replies
linuxoid's avatar

That .htaccess is in my /blog/public folder. But I can't get to it from the blog's one unless I directly go to /blog/public

bugsysha's avatar

Yes, cause you've pointed only to the blog folder. Add on the public folder to that and it should work.

linuxoid's avatar

Are you talking about the .htaccess in the blog folder or one in the blog/public?

Snapey's avatar

change the document root in apache config to be the public folder of your project then restart apache

The .htaccess should be the one that ships with Laravel

linuxoid's avatar

are you suggesting to make separate virtual hosts for each project?

Snapey's avatar

That would be the point of using virtual hosts in apache. Yes, one project, one virtual host.

You will need to give each its own unique servername

bugsysha's avatar

are you suggesting to make separate virtual hosts for each project?

Definitely. But if you are feeling lazy like me lately, then I just use php artisan serve.

linuxoid's avatar

I'm feeling lazy in a way that I want all my projects to be served from one user folder with .htaccess redirections where required. All I need is just to get the blog folder redirected to the blog/public but it doesn't work.

Going 'root' and playing with server config every time I set up a project folder doesn't seem quite right. BTW the server configs can be lost during system upgrade.

Snapey's avatar

putting all your projects under one document root will a) cause lots of unexpected difficulties, b) not be representative of actual production hosting, causing issues when you come to deploy your project.

bugsysha's avatar

Buy a Mac and use Laravel Valet. That solves being lazy in the way you want to be lazy.

linuxoid's avatar

is there a good doc on how to move from local to shared server? I read it's just a matter of "copy/paste" and changing the .env and some other cofigs. Isn't this so?

I expect on a host server I'll have to set a redirect from a project folder to the project/public in any case anyway. So why can't I have it on my local machine? What are the difficulties?

bugsysha's avatar

I read it's just a matter of "copy/paste" and changing the .env and some other cofigs. Isn't this so?

In theory yes, in real life NO.

So why can't I have it on my local machine? What are the difficulties?

@snapey pointed out some of them.

Please or to participate in this conversation.