Redirect from http to https sometimes fails

Please fill out the fields below so we can help you better. Note: you must provide your domain name to get help. Domain names for issued certificates are all made public in Certificate Transparency logs (e.g. crt.sh | example.com), so withholding your domain name here does not increase secrecy, but only makes it harder for us to provide help.

My domain is: ptm.apptimber.com

I ran this command:

It produced this output:

My web server is (include version): Apache 2.4.41

The operating system my web server runs on is (include version): Ubuntu 20.04.2

My hosting provider, if applicable, is: Digital Ocean

I can login to a root shell on my machine (yes or no, or I don't know): Yes

I'm using a control panel to manage my site (no, or provide the name and version of the control panel): No

The version of my client is (e.g. output of certbot --version or certbot-auto --version if you're using Certbot): 0.40.0

I am sometimes get a bad request error 400 on my browser:
image

My virtual host configurations are:
GNU nano 4.8 ptm.conf

<VirtualHost *:80>
    ServerName ptm.apptimber.com
    ServerAlias www.ptm.apptimber.com
    ServerAdmin vanjoe@apptimber.com
    DocumentRoot /var/www/ptm/public_html/ptm

    <Directory /var/www/ptm/public_html/ptm>
     Options FollowSymLinks
     AllowOverride ALL
    </Directory>

   # <Directory /var/www/ptm/public_html/ptm/phpmyadmin>
   #   Options FollowSymLinks
   #   DirectoryIndex index.php
   #   AllowOverride All        
   # </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.ptm.apptimber.com [OR]
RewriteCond %{SERVER_NAME} =ptm.apptimber.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerName ptm.apptimber.com
    ServerAlias www.ptm.apptimber.com
    ServerAdmin vanjoe@apptimber.com
    DocumentRoot /var/www/ptm/public_html/ptm

    <Directory /var/www/ptm/public_html/ptm>
     Options FollowSymLinks
     AllowOverride ALL
    </Directory>

   # <Directory /var/www/ptm/public_html/ptm/phpmyadmin>
   #   Options FollowSymLinks
   #   DirectoryIndex index.php
   #   AllowOverride All        
   # </Directory>

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

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

Am i missing some directive?

I cannot reproduce that error. HTTP redirects consistently to HTTPS for me.

We cannot see all of your Apache config. Please edit your post and add 3 backticks before and after the Apache config so we don't lose needed info. Like this:

```
the Apache VirtualHosts
```

3 Likes

You did not show the URL [in that picture].

[also: I added the three backticks to your original post]

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.