Question

Broken HTTPS:// links after Installing Certbot software and configuring HTTPS on laravel application, Apache, Ubuntu 20.04 | DigitalOcean

Posted October 31, 2020 182 views
ApacheLet's EncryptLaravelUbuntu 20.04

I successfully deployed a Laravel application on Apache Ubuntu 20.04 in Digital Ocean, everything was fine until I installed CertBot software to configure HTTPS on my Apache server. After installing and setting up certbot, when i visit the homepage via HTTPS:// link, it works fine but when I tried to visit other pages via HTTPS:// link, i get the error below:

Not Found

The requested URL was not found on this server. Apache/2.4.41 (Ubuntu) Server at mysite.com Port 443

I followed the guide in this link: https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-20-04

Below is my Apache Config files

mysite.com.conf

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName mysite.com
        ServerAlias www.mysite.com
        DocumentRoot /var/www/mysite.com/mysite-web-app/public

        <Directory /var/www/mysite.com/mysite-web-app/public>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>

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

        <IfModule mod_dir.c>
            DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
        </IfModule>

RewriteEngine on
RewriteCond %{SERVER_NAME} =www.mysite.com [OR]
RewriteCond %{SERVER_NAME} =mysite.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

mysite.com-le-ssl.conf

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerAdmin webmaster@localhost
    ServerName mysite.com
    ServerAlias www.mysite.com
    DocumentRoot /var/www/mysite.com/mysite-web-app/public
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/mysite.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mysite.com/privkey.pem
</VirtualHost>
</IfModule>

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

You must include this in the ssl conf as well:

  <Directory /var/www/mysite.com/mysite-web-app/public>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    <IfModule mod_dir.c>
        DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
    </IfModule>

Or the .htaccess won’t work for https connections.

See Answer on stackoverflow:
https://stackoverflow.com/questions/64625322/broken-https-links-after-installing-certbot-software-and-configuring-https-on/64625548#64625548

Submit an Answer