.htaccess optimization tip!!
-
Hello,
I got errors from Google PageSpeed Insights ‘Avoid Landing Page Redirects’. The .htaccess code causes for 2 redirects instead of one.
Browser -> http://[domain].com -> (redirect) https://[domain].com -> (redirect) https://www.[domain].com
That gives you 2 redirects.
Instead of using
# BEGIN HTTPS Redirection Plugin <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] </IfModule> # END HTTPS Redirection PluginTry to use this code:
# BEGIN HTTPS Redirection Plugin <IfModule mod_rewrite.c> RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteCond %{HTTP_HOST} ^(www\.)?(.*)$ [NC] RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] </IfModule> # END HTTPS Redirection PluginIt now uses one redirect instead of 2.
The topic ‘.htaccess optimization tip!!’ is closed to new replies.