Apache Webserver

Leverage browser caching for .htaccess

How to do Leverage browser caching for .htaccess. Below code will tells browsers what to cache and how long to “remember” it a browser.  Top of your .htaccess file place below code. ## EXPIRES CACHING ## <IfModule mod_expires.c> ExpiresActive On ExpiresByType image/jpg “access 1 year” ExpiresByType image/jpeg “access 1 year” ExpiresByType image/gif “access 1 year” ExpiresByType image/png …

Leverage browser caching for .htaccess Read More »

Redirect Non WWW to WWW Using .htaccess

Redirect non www to www using your domain name RewriteCond %{HTTP_HOST} ^example.com$ RewriteRule (.*) http://www.example.com/$1 [R=301,L] Or use this for any domain: RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] If you have ssl enabled then add this two line for http to https redirect RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Redirect HTTP traffic to HTTPS using an .htaccess

Create a .htaccess file then write this code you will redirect all HTTP traffic to HTTPS. ##Global Http to Https Redirect RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L] If you want a single page to redirect http to https then use this code. ## single page redirect RewriteEngine On RewriteRule ^redirect-http-to-https-page\.html$ https://www.example.com/redirect-http-to-https-page.html [R=301,L]