Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

tracy's avatar
Level 1

Why http not redirect to https although ssl certificate already installed and configure in apache2 web server

i get problem with ssl . i hosted laravel app on AWS EC2 ubuntu with apache 2 . domain use from hostinger , i pointed domain from AWS route 53 hosted zone with record A and CNAME , i installed certbot ssl for my domain and configure in 000-default.conf



<VirtualHost *:80>
	# The ServerName directive sets the request scheme, hostname and port that
	# the server uses to identify itself. This is used when creating
	# redirection URLs. In the context of virtual hosts, the ServerName
	# specifies what hostname must appear in the request's Host: header to
	# match this virtual host. For the default virtual host (this file) this
	# value is not decisive as it is used as a last resort host regardless.
	# However, you must set it for any further virtual host explicitly.
	#ServerName www.example.com

	ServerAdmin webmaster@localhost
        ServerName domain.com
        ServerAlias www.domain.com
	DocumentRoot /var/www/html/revo/public
           
        

      <Directory /var/www/html/revo/public>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
      </Directory>

	# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
	# error, crit, alert, emerg.
	# It is also possible to configure the loglevel for particular
	# modules, e.g.
	#LogLevel info ssl:warn

	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined
        
        RewriteEngine On
        RewriteCond %{HTTPS} off
        RewriteRule ^(.*)$ https://%{SERVER_NAME} [R,L]
        
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
<VirtualHost *:443>
    DocumentRoot "/var/www/html/revo/public"
    ServerName domain.com
    ServerAlias www.domain.com

      <Directory /var/www/example>
                Options -Indexes +FollowSymLinks +MultiViews
                AllowOverride All
                Require all granted
        </Directory>
        SSLEngine on

       SSLInsecureRenegotiation off

               
        Include /etc/letsencrypt/options-ssl-apache.conf
        SSLCertificateFile /etc/letsencrypt/live/domain.com/fullchain.pem
        SSLCertificateKeyFile  /etc/letsencrypt/live/domain.com/privkey.pem
  
       <Location "/webhook/coinbase">
        # Configuration specific to handling the /webhook/coinbase URL
        # You can add additional directives here as per your requirements

        # Example: ProxyPass to forward the request to a different backend
        ProxyPass http://domain.com/webhook/coinbase
        ProxyPassReverse http://domain.com/webhook/coinbase
    </Location>

 
</VirtualHost>


after restart apache . when i type my domain name ,it show with no SSL , only show http , but when i type with https://domain,com , it show with ssl .

what wrong with that . i dont need to type https:// to see ssl domain

why http cannot redirect to https .

what wrong in configuration file

0 likes
1 reply
Snapey's avatar
Snapey
Best Answer
Level 122

I ask letsencrypt to redirect http to https and it adds the following to the port 80 .conf file

RewriteEngine on
RewriteCond %{SERVER_NAME} =domain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

Yours:

        RewriteEngine On
        RewriteCond %{HTTPS} off
        RewriteRule ^(.*)$ https://%{SERVER_NAME} [R,L]
1 like

Please or to participate in this conversation.