Why all the directories of my laravel application is indexed in google?

121 Views Asked by At

My application is in Laravel + Vue I'v hosted on Hostinger VPS ubuntu 20. when I type my site in Google like mywebsite.com google showing all the directories.

This is my site config

<VirtualHost *:80>
   ServerName mywebsite.com
   ServerAlias www.mywebsite.com
   ServerAdmin [email protected]
   DocumentRoot /var/www/html/mywebsite/public

   <Directory /var/www/html/mywebsite>
        AllowOverride All
        Options -Indexes
        Require all granted
        ReWriteEngine On
   </Directory>
   ErrorLog ${APACHE_LOG_DIR}/error.log
   CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.mywebsite.com [OR]
RewriteCond %{SERVER_NAME} =mywebsite.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

This is the .htaccess file

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

Does anyone know What I'm missing in the configuration.

for the ssl I use Letsencypt cerbot.

2

There are 2 best solutions below

1
mohammad hosein abedini On

Add public to your path in Directory and this probably will solve your problem

<Directory /var/www/html/exptradies/public>
        AllowOverride All
        Options +FollowSymlinks
        Require all granted
        ReWriteEngine On
   </Directory>

Don't forget to restart apache service

7
Stephen Ostermiller On

Your web server is configured to show directory indexes. That shows a web page with a list of files for directory requests when the directory does not contain an index document. You can disable this by using

Options -Indexes

That can either go beneath AllowOverride All or in your .htaccess file. If you make changes to your Apace configuration files, you will need to restart Apache or tell it to reload its conf files before they take effect.

Another workaround is to create blank index.html files in each directory that is currently showing the file listing. Search engines will treat that as a "soft 404" error which will prevent it from getting indexed.

After making changes, test that you can't browse those directories and see the file listing anymore. Then you will have to wait a couple weeks for Googlebot to recrawl those pages and stop indexing them.