Category Archives: Tutorial

Add SSL and secure WordPress with HTTPS

Hello Coders…

Today lets see how to configure wordpress to have https based request.

So many have a question that first of all what is SSL and why HTTPS?

We share our personal information with different websites whether it’s making a purchase or for logging in on daily basis. In order to protect the data transfer, a secure connection needs to be created. That’s when SSL and HTTPS come in.
HTTPS or Secure HTTP is an encryption method that secures the connection between users’ browser and your server. This makes it harder for hackers to eavesdrop on the connection. Each site is issued a unique SSL certificate for identification purposes. If a server is pretending to be on HTTPS, and it’s certificate doesn’t match, then most modern browsers will warn the user from connecting to the site.

Recently, Google also announced that they will be using HTTPS and SSL as a ranking signal in their search results. This means that using HTTPS and SSL will help improve your site’s SEO.

Where to get SSL?

Many hosting service provider give SSL certificate for websites. We also provide SSL certificate as our product you can contact us we will provide SSL certificate around INR 850 (USD 12) or else you can approach other provider like godaddy. Some web hosting providers provide hosting with free SSL. we also provide web hosting with free SSL. You can have service through such providers to have SSL for your domain.

Mostly SSL configuration can be done with support of hosting service provider so we are much concentrated towards configuring wordpress for accepting HTTPS connection

How to setup wordpress to use HTTPS connection?

If you installing wordpress through softaculous then there is an option to select http / https during installation process so that it will write .htaccess file based on that.

If you installed directly through manual installation or already existing site then you can navigate to settings -> general settings under which you can see wordpress address and site address which in default have http you need to change it to https as given in below screenshot

Once it done your wordpress site will be redirect to https from http.

You can also do this by adding following code in .htaccess above wordpress .htaccess rules.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.yoursite.com/$1 [R,L]
</IfModule>

change yoursite.com to your domain name. This will make your wordpress site redirect to https. Even for normal site also this will make redirection to https.

Thanks for reading… Happy coding…

Drop your feedback in comments…

Route CodeIgniter Controllers In Multi Level Subfolder

I was working on a project which actually requires to handle multi level subfolders for codeigniter. Usually codeigniter can handle only one subfolder. But this reduce capability of it and I am always not like to change codes in CI core. So i did some research on this found a simple solution by custom routing to extend CI core.

  1. Create a file Named “MY_Router.php” in CI application/libraries folder.
  2. Copy paste following script in it.
    <?php
    defined('BASEPATH') OR exit('No direct script access allowed');
    /**
     * CodeZone.in
     * Author: Dineshkumar
     * Contact : hi@codezone.in
     * Add functionality to read into more than one sub-folder of controller
     * Compatible with Codeigniter 3.x
     *
     */
     
    Class MY_Router extends CI_Router
    {
        Function MY_Router()
        {
            parent::__construct();
        }
    
        function _validate_request($segments)
        {
    
           if (file_exists(APPPATH.'controllers/'.$segments[0].".php"))
            {
                return $segments;
            }
    
            if (is_dir(APPPATH.'controllers/'.$segments[0]))
            {
                $this->set_directory($segments[0]);
                $segments = array_slice($segments, 1);
    
                /* ----------- CHECK SUB FOLDER STARTS ------------ */
    
                while(count($segments) > 0 && is_dir(APPPATH.'controllers/'.$this->directory.$segments[0]))
                {
                if (substr($this->directory, -1, 1) == '/')
                    $this->directory = $this->directory . $segments[0];
                else
                    $this->directory = $this->directory . '/' . $segments[0];
    
                $segments = array_slice($segments, 1);
                }
    
                if (substr($this->directory, -1, 1) != '/')
                    $this->directory = $this->directory . '/';
    
                /* ----------- CHECK SUB FOLDER ENDS ------------ */
    
                if (count($segments) > 0)
                {
    
                    if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().'/'.$segments[0].".php"))
                    {
                        show_404($this->fetch_directory().$segments[0]);
                    }
                }
                else
                {
                    $this->set_class($this->default_controller);
                    $this->set_method('index');
    
                    if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().'/' .$this->default_controller.".php"))
                    {
                        $this->directory = '';
                        return array();
                    }
    
                }
    
                return $segments;
            }
    
            show_404($segments[0]);
        }
    }
  3. Don’t look for more steps its over. 😛

Just your codeigniter framework capability is extended to handle

Background Image auto scaling using CSS

Hi guys today I am going to explain about a CSS property known as background-size. This helps in image auto scaling based on screen view. Usual case we use textures to fill background using repeat property. Some time we use single image as background. We can’t use very large time which will take more bandwidth and so we use optimized images. This should auto scale and fit background. To achieve this we can use background-size property of CSS. For an Example

 

/**
 * CodeZone.in
 * Author: Dineshkumar
 * Contact : hi@codezone.in
 */
 body {
    background-image:    url(images/background.jpg);
    background-size:     cover;                      /* <------ */
    background-repeat:   no-repeat;
    background-position: center center;              /* optional, center the image */
}

In above example we can give cover as value of background-size property or contain. To demonstrate how this two input value make effect in display let us consider below image as screen in which grey area are out of your visible screen.

rcjke

contain:

If we use this property then image will be fit inside visual area and which may have some blank space which can be filled with background-color property as show in below image.

matcl

Cover:

This makes sure that background is covered everything based on that image will be scaled. So it is like auto scale to cover your entire background. To make you understand please see below image.

p96p5

Hope you understand the concept behind this property.

Happy Coding….

Delete A Repository in BitBucket

Hi as a professional developer we always keen to organize source code through git hub or bitbucket. After creating repository sometime we are in situation to delete such repositories. In bit bucket you can able to do that through following steps:

  1. Log into your Bitbucket account.
  2. Navigate to the repository you want to delete.
  3. Click the repository’s  settings icon.
  4. Choose Delete Repository from the left-hand navigation.
    The system displays the deletion dialog.
  5. (Optional) Enter a URL in the Redirect to field.
    Future users who try to access your repository are sent to this new URL.
  6. Press Delete repository.

Happy Coding…

String to Hex & Hex to String Conversion in PHP

Hi Guys I just gone through a situation need to convert string to Hex but unfortunatly not found any Pre-build function in PHP but don’t worry today I would like to share you a function which solve the purpose in either way

String to Hex Function

/**
 * CodeZone.in
 * Author: Dineshkumar
 * Contact : hi@codezone.in
 */
 function string2hex($string){
    $hex = '';
    for ($i=0; $i<strlen($string); $i++){
        $ord = ord($string[$i]);
        $hexCode = dechex($ord);
        $hex .= substr('0'.$hexCode, -2);
    }
    return strToUpper($hex);
}

Hex to String Function

/**
 * CodeZone.in
 * Author: Dineshkumar
 * Contact : hi@codezone.in
 */
 function hex2string($hex){
    $string='';
    for ($i=0; $i < strlen($hex)-1; $i+=2){
        $string .= chr(hexdec($hex[$i].$hex[$i+1]));
    }
    return $string;
}

Usage:

Include function in your PHP script and call them with required parameters to get your converted output.

Happy Coding….