If directive not working in apache VirtualHost conf, says "Invalid command"

"If" is not something Apache understands (before version 2.3). You probably should look at mod_rewrite

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/(.*) https://example.com:443/$1 [R,L]

To find your apache version you can probably use: apache2 -v