Wednesday, 26 October 2016

Configure .htaccess file

When we are going to launch website, then It's good to configure .htaccess file for some redirecting facility, fixing canonical issue and calling 404 Error Page and upload this file into main root of your server.

Also you can include gzip compression, Leverage Browser Caching code in .htaccess file for fast loading your website.

So, here is what, i am telling you some important redirection and fixing canonical issue.

1:) Canonical Issue: For redirecting your non www website to www, include below code.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain-name\.com [NC]
RewriteRule ^(.*)$ http://www.domain-name.com/$1 [L,R=301]  [301 permanent Re-direction]


2.) Redirect your Home Page to the Domain: It's good to crawl your Domain, as a Home Page of your website for getting more attention of search engines.

HTML

RewriteEngine On
  Redirect 301  /http://www.domain-name.com/index.html  http://www.domain-name.com

PHP

RewriteEngine On
   Redirect 301  /http://www.domain-name.com/index.php http://www.domain-name.com

ASP.NET

RewriteEngine On
  Redirect 301  /http://www.domain-name.com/default.aspx http://www.domain-name.com

OR

RewriteRule ^index\.html$ / [NC,R,L]


3:) Calling 404 Page: If any web address you want to visit, doesn't exist, then 404 error page comes.

ErrorDocument 404 /404.html

ErrorDocument 404 /404.php


4:) Enabling gzip Compression: GZIP compression, is based on lossless compression method for compressing text data in websites, which is good for speeding up your website.

You can take code from : https://gtmetrix.com/enable-gzip-compression.html


5:) Leverage Browser Caching:  This procedure stored your website file in the visitor browser locally and creates browser cache, which helps for reducing load time of your website.

You can take code from : https://gtmetrix.com/leverage-browser-caching.html




No comments:

Post a Comment