I'm trying to run laravel on EC2(AWS linux 2) and apache server. And I recently bought a domain from Namecheap

enter image description here

And I installed laravel to var/www/html folder.

My /etc/httpd/conf/httpd.conf has those lines,

DocumentRoot "/var/www/html/public"

<Directory "/var/www/html">

    AllowOverride All

    # Controls who can get stuff from this server.
    Require all granted

And this is my /etc/httpd/conf.d/vhost.conf is this

<VirtualHost *:80>

  ServerName mydomain.store

  ServerAlias https://www.mydomain.store

  DocumentRoot /var/www/html/public

  ServerAdmin mailto:[email protected]

  <Directory /var/www/html>
    AllowOverride All

RewriteEngine on
RewriteCond %{SERVER_NAME} =mydomain.store [OR]
RewriteCond %{SERVER_NAME} =https://www.mydomain.store
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

And I added SSL via sudo certbot --apache

And when I add like this in browser (Not real IP) my app works fine. But when I add https://mydomain.store in browser I get file structure like this,

enter image description here

And when I add https://mydomain.store/public in browser app works.

Does anyone know why?

1 Answer 1


After lots of effort find the answer myself. Posting it thinking it may help someone like me in the future.

I used Let’s Encrypt for creating ssl and it automatically create an virtual host for port 443 (https) inside vhost-le-ssl.conf file.

So we need to access the file,

sudo vi /etc/httpd/conf.d/vhost-le-ssl.conf

And change document root there to (point to public folder),

DocumentRoot /var/www/html/public

And restart apache after that.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .