htttp to https redirect

Help me to configure my ssl certificate.
I am not able to redirect http to https. My website is wordpress powered.

My .htaccess file code is below-

# BEGIN WordPress

    # 4 weeks
    <FilesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|swf)$">
        Header set Cache-Control "max-age=2419200, public"
    </FilesMatch>

    # 2 DAYS
    <FilesMatch ".(xml|txt)$">
        Header set Cache-Control "max-age=172800, public, must-revalidate"
    </FilesMatch>

    # 2 HOURS
    <FilesMatch ".(html|htm|css)$">
        Header set Cache-Control "max-age=7200, must-revalidate"
    </FilesMatch>

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
        RewriteRule ^index.php$ - [L]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule . /index.php [L]
    </IfModule>

    <ifModule mod_gzip.c>
        mod_gzip_on Yes
        mod_gzip_dechunk Yes
        mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
        mod_gzip_item_include handler ^cgi-script$
        mod_gzip_item_include mime ^text/.*
        mod_gzip_item_include mime ^application/x-javascript.*
        mod_gzip_item_exclude mime ^image/.*
        mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
    </ifModule>

# END WordPress

please tell me what to do to redirect all pages of my site “http://example.com” to “https://example.com

Related posts

Leave a Reply

2 comments

  1. Use this in your htaccess file

    RewriteEngine On
    
    RewriteCond %{HTTPS} off
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    
    RewriteBase /
    RewriteRule ^index.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    
  2. There are lots of questions already answered on this. It can, however, be done with the following lines in your .htaccess.

    RewriteEngine On
    RewriteCond %{HTTPS} !=on
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    

    The first line turns the rewrite engine on. The second line is a conditional to check that HTTPS is not currently ‘on’ already, and the third line is the action to carry out if that condition is true which, in this case, is to redirect to the current URL over HTTPS.