Friday, 8 June 2012

Basics Concept of SEO

Simply SEO stands for Search Engine Optimization OR Search Engine Optimizer.

There are two parts of SEO:
i) On Page Optimization.
ii) Off Page Optimization.

On Page Optimization: This ensures that website pages are optimized properly so that search engine know that for what purpose pages are created.
 Off Page Optimization: Off page optimization calculates all back links for any website from another website. Because search engine treat backlinks as vote, so backlinks are very important for ranking.

Thursday, 7 June 2012

What is Subdomain?

Subdomains are second level of domains or its substiture. If main domain is www.mymaindomain.com, then subdomain can be http://subdomain.mymaindomain.com.

Merits:
1) Cost Saving: If any organization want to buy 100 domains for different subject it will cost (100*perdomain cost). But subdomain cost free. So it will cost 0 for 1-10000 (depending upon provider how many subdomains they provide.) subjects.

2) Since all search engines treat subdomains as different for indexing. Like www.mymaindomain.com AND http://subdomain.mymaindomain.com are two different domains for search engines. So website owner get all the benefits of keyword rich website without registering extra domain and hosting cost.


Wednesday, 6 June 2012

Introduction of MySql Cursor

 Mysql supports curosr inside stored programs. This is an embedded SQL. Cursors have  some  properties:

i) Asensitive - Server may or may not make a copy of its result table.

ii) Its read only. It means it can't update.

iii) Nonscrollable: It can traversed only one direction, and rows can't skip.

To be noted: Cursor should must appear before handler declarations and after variable and condition declarations.

Example:


CREATE PROCEDURE myCurDemo()
BEGIN
  DECLARE done INT DEFAULT FALSE;
  DECLARE a CHAR(16);
  DECLARE b, c INT;
  DECLARE mycur1 CURSOR FOR SELECT id,data FROM test.table1;
  DECLARE mycur2 CURSOR FOR SELECT id FROM test.table2;
  DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;

  OPEN mycur1;
  OPEN mycur2;

  read_loop: LOOP
    FETCH mycur1 INTO a, b;
    FETCH mycur2 INTO c;
    IF done THEN
      LEAVE read_loop;
    END IF;
    IF b < c THEN
      INSERT INTO test.table3 VALUES (a,b);
    ELSE
      INSERT INTO test.table3 VALUES (a,c);
    END IF;
  END LOOP;

  CLOSE mycur1;
  CLOSE mycur2;
END;

Tuesday, 5 June 2012

URL Rewriting and SEO

What is URL rewriting?

Most dynamic websites uses variables in the URLs to pass values like: http://www.mywebsite.com/myproducts.php?id=1, which is not SEO friendly. But in the sense of SEO this URL can be change to http://www.mywebsite.com/products/7. This can be done by URL rewriting on .htaccess on Apache environement. To achieve this mod_rewrite module should be ON. IIS (Microsoft server) doesn't include this functionality but using add-ons it can be used. ISAPI_Rewrite can be used to mod_rewrite functionality in IIS environment.

1) Simple replacement:

http://www.mywebsite.com/product_details_and_info.php

RewriteEngine On # Turn on the rewriting engine
RewriteRule ^product-details/?$ product_detals_and_info.php [NC,L]

The above code will change URL below:

http://www.mywebsite.com/product-details/

2) Match pattern and replacement:

http://www.mywebsite.com/product_lists.php?pid=10

RewriteRule ^products/([0-9]+)/?$ product_lists.php?pid=$1 [NC,L]

http://www.mywebsite.com/products/10/

Here $1 will replace all number in pid (like pid=10) with pid number after products (like /products/10).

3) Regular Expression match:

Because this pattern match with regular expression(RE) so be careful with special characters of RE.

RewriteRule ^rssfeed.xml$ rssfeed.php [NC,L]

Above example will not only match rssfeed.xml but also will match rssfeed1xml, rssfeed-xml. So to avoid this use below code.

RewriteRule ^rssfeed\.xml$ rssfeed.php [NC,L]

Other escaping character lists are:

     . => Any character
     * => Zero or more of the preceding
     + => One or more of the preceding
     {} => Minimum to maximum quantifier
     ? => Ungreedy modifier
     ! => Negative Pattern OR At start of string
     ^ => Start of string, or negative if at the start of a range
     $ => End of string
     [] => Match any of contents
     - => Range if used between square brackets
     () => Group, backreferenced group
     | => Alternative, OR
     \ => The escape character itself

4) Content Moved

RewriteRule ^articles/?$ http://www.mywebsite.com/articles/ [R,NC,L]

Here R flag denotes that articles is moved temporarily. Either a substitution URL can be given or header will sent back a code 302, it means moved temporarily.

RewriteRule ^article/?$ http://www.new-domain.com/article/ [R=301,NC,L]

Here R=301 shows that content is moved permanentaly.

Other Flags:
     C => Chained with next rule
     CO=cookie => Set specified cookie
     E=var:value => Set environment variable var to value
     F => Forbidden - sends a 403 header to the user
     G => Gone means no longer exists
     H=handler => set handler
     L => Last - stop processing rules
     N => Next - continue processing rules
     NC => Case insensitive
     NE => Do not escape special URL characters in output
     NS => Ignore this rule if the request is a subrequest
     P => Proxy
     PT => Pass through ( when processing URLs with additional handlers, e.g., mod_alias)
     R => Temporary redirect to new URL
     R=301 => Permanent redirect to new URL
     QSA => Append query string from request to substituted URL
     S=x => Skip next x rules
     T=mime-type => Force specified mime type


What is $_SERVER ??

$_SERVER is a superglobal array in PHP. It contains following values:

    $_SERVER['UNIQUE_ID']
    $_SERVER['HTTP_HOST']
    $_SERVER['HTTP_USER_AGENT']
    $_SERVER['HTTP_ACCEPT']
    $_SERVER['HTTP_ACCEPT_LANGUAGE']
    $_SERVER['HTTP_ACCEPT_ENCODING']
    $_SERVER['HTTP_ACCEPT_CHARSET']
    $_SERVER['HTTP_KEEP_ALIVE']
    $_SERVER['HTTP_CONNECTION']
    $_SERVER['HTTP_CACHE_CONTROL']
    $_SERVER['PATH']
    $_SERVER['SERVER_SIGNATURE']
    $_SERVER['SERVER_SOFTWARE']
    $_SERVER['SERVER_NAME']
    $_SERVER['SERVER_ADDR']
    $_SERVER['SERVER_PORT']
    $_SERVER['REMOTE_ADDR']
    $_SERVER['DOCUMENT_ROOT']
    $_SERVER['SERVER_ADMIN']
    $_SERVER['SCRIPT_FILENAME']
    $_SERVER['REMOTE_PORT']
    $_SERVER['GATEWAY_INTERFACE']
    $_SERVER['SERVER_PROTOCOL']
    $_SERVER['REQUEST_METHOD']
    $_SERVER['QUERY_STRING']
    $_SERVER['REQUEST_URI']
    $_SERVER['SCRIPT_NAME']
    $_SERVER['PHP_SELF']
    $_SERVER['REQUEST_TIME']

Sunday, 3 June 2012

File Location in LAMP Environment.

1) php.ini
      It depends upon Linux distribution and PHP Version , but some common locations may be:

a) /etc/php.ini
b) /etc/php/php.ini
c) /etc/php5/php.ini
d) /usr/bin/php5/bin/php.ini
 OR

find by command: find / -name php.ini   

Saturday, 2 June 2012

Benefits of Stored Procedures.

Advantages of Stored Procedures:

1) Stored porcedures separates database access logic from the application logic.

2) SQL can be pre-compiled which increases the speed of the application.

3) More processing can be done on database server due to stored procedures contain program logic, which reduces bandwidth consumed to sending data back to the application.

4) On the implementation of n-tier application, stored procedures separates the data layer from the server layer.

5) Applications can be grant execute privileges to the stored procedures, while being unable to access the tables directly. It enables security feature of stored procedure.