.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 -> https://[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 Plugin
Try 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 Plugin
It now uses one redirect instead of 2.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘.htaccess optimization tip!!’ is closed to new replies.