1

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"

Joe
  • 15,669
  • 4
  • 48
  • 83
ramendra
  • 41
  • 3
  • you should do some effort before asking here, have you used the search box before your question of this community? – jogesh_pi Sep 10 '14 at 11:55

2 Answers2

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]
jogesh_pi
  • 9,762
  • 4
  • 37
  • 65
1

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.

Mike
  • 8,767
  • 8
  • 49
  • 103