I have successfully configured the SSL certificate for my client’s website.
Let me give you some technical information.
Website has been developed in Wordpress.
Server is from AWS with Ubuntu 16.04 with apache.
I have already entered .htaccess rules for the website.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#RewriteCond %{HTTP_HOST} !^www\.
#RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# force https:// for all except some selected URLs
RewriteCond %{HTTPS} off
RewriteCond %{THE_REQUEST} !/ticket-status/ [NC]
RewriteCond %{THE_REQUEST} !/servicerequest/ [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# force http:// for selected URLs
RewriteCond %{HTTPS} on
RewriteCond %{THE_REQUEST} /ticket-status/ [NC]
RewriteCond %{THE_REQUEST} /servicerequest/ [NC]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
<IfModule mod_expires.c>
ExpiresActive On
# Images
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
ExpiresByType image/x-icon "access plus 1 year"
# Video
ExpiresByType video/mp4 "access plus 1 year"
ExpiresByType video/mpeg "access plus 1 year"
# CSS, JavaScript
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
# Others
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
</IfModule>
My problem is when I open the website it takes sometime to redirect from http to https and after that website works normally with good speed.
Let me know if I need to change something in above .htaccess code and/or I need to change/check something on server side too?
Nice find, @JuergenAuer! @bhargav_webtech, one thing that makes this confusing is that your browser will display “redirecting to https://www.cera-india.com/” while it is waiting for an answer on the HTTPS URL. But that doesn’t mean the redirect is slow, it means the target of the redirect (your website) is slow.
You can test this out yourself. Load https://www.cera-india.com/ (the HTTPS version) directly in your web browser. You will see that it is slow even without the redirect.
I don’t know if this has an impact on your web server delay but got this from Apache.org.
You should avoid using .htaccess files completely if you have access to httpd main server config file. Using .htaccess files slows down your Apache http server. Any directive that you can include in a .htaccess file is better set in a Directory block, as it will have the same effect with better performance.