Laravel Apache2 Https No Pretty URL

Viewed 35

I installed laravel on a new server, with certbot I installed a new HTTPS certificate but the pretty urls don't work.

Via HTTP there are no problems, but as soon as I access HTTPS it seems that mod_rewrite does not work

This is the apache HTTP configuration

<VirtualHost *:80>
    ServerAdmin admin@example.com
    ServerName mydomain.it
    DocumentRoot /var/www/example-app/public

    <Directory /var/www/example-app/public>
    Options Indexes MultiViews
    AllowOverride None
    Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Questa la configurazione HTTPS:

<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerName mydomain.it
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/example-app/public


        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        <Directory /var/www/example-app/public>
            Options Indexes MultiViews
            AllowOverride None
            Require all granted
         </Directory>


        Include /etc/letsencrypt/options-ssl-apache.conf
        SSLCertificateFile /etc/letsencrypt/live/mydomain.it/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.it/privkey.pem
        </VirtualHost>
</IfModule>

I also attach htaccess but it is the default of laravel:

<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>
1 Answers

Change the default ssl configuration file in VirtualHost resolve the problem:

<Directory /var/www/example-app/public>
   AllowOverride all
 </Directory>
Related