Wednesday 30 October 2013

No WWW Using .htaccess

There are some clear benefits to removing the "www" from your URLs:
  • Shorter URLs
  • Prevention of Google search engine penalties for duplicate content
  • Less bandwidth usage if you have many links per page
Luckily, removing the WWW from your page URLs (and subsequent Google listings) can be done inside your .htaccess file so that you wont have to go into every page on your website and remove the "www" from your anchors.

The .htaccess Code

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]
 
Conversely, if you'd prefer to use "www" in all of your URLs, you can code:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
 
Save some URL characters and remove WWW from your site!

Friday 6 September 2013

PHP compiler - HipHop

HipHop is a execution engines and improvements created by Facebook. 
HipHop was develop to save resources on Facebook servers. 
HipHop is currently around 1.9 million lines of mostly C++, C and PHP source code and is distributed as open source. 
It programmatically transforms your PHP source code into highly optimized C++ and then uses g++ to compile it.

Friday 7 June 2013

Export CSV file in PHP

  header("Content-type:text/octect-stream");
  header("Content-Disposition:attachment;filename=data.csv");
 $recordlist = $this->db->query("SELECT * FROM `table` ");

        foreach($recordlist ->result_array() as $row)
        {
            print '"' . stripslashes(implode('","',$row)) . "\"\n";
        }
        exit;

How to enable gzip compression using cpanel

Login into cpanel  -> Software/Services -> Optimize Website -> Now Click on 'Compress all content'

Now check your site performance using this site
http://gtmetrix.com/















Monday 22 April 2013

A WordPress blog in CakePhp site.

Create a folder blog in app->webroot in cakephp site.

Upload your wordpress blog in this folder.

Modify your root .htaccess  file in cakeph.

<IfModule mod_rewrite.c>
   RewriteEngine on
   RedirectMatch temp ^/blog/wp-admin$ site_name/blog/
    RewriteRule ^blog$ blog/ [L]
    RewriteRule ^blog/wp-admin$ blog/wp-admin/ [L]
   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>

Now admin URL
site_name/blog/wp-login.php