Skip to main content

Posts

Showing posts from November, 2017

Setting a Custom 404 Error Page in .htaccess

We have to handle error page request by .htaccess like if someone requesting for 404,500 type of request/errors. These are some of the most common errors: 401 – Authorization Required 400 – Bad request 403 – Forbidden 500 – Internal Server Error 404 – Wrong page To handle these request/errors follow below code. # Error pages handling errorDocument 401 http://www.youwebsite.com/error_401.html errorDocument 400 http://www.youwebsite.com/error_400.html errorDocument 403 http://www.youwebsite.com/error_403.html errorDocument 500 http://www.youwebsite.com/error_500.html errorDocument 404 http://www.youwebsite.com/error_404.html Each time if someone request for wrong page(404) he will be automatically redirected to error_404.html page, You can customize these pages as per you need. If you want to disable whole directory then put below code in your .htaccess file # Disable directory browsing, Nobody directly browse your directory. Options All -Indexes

Common MySql Interview Questions and Answers For Experienced/Freshers

Some Common MySql Interview Questions and Answers For Experienced + Freshers Which mostly asked my interviewer during interview session, As you know MySql is highly popular relational database and good compatible with open source languages like PHP. Following list of basic Mysql question and answer surely help developers for getting new jobs. MySql Interview Questions and Answers Question: What is MySQL? MySQL is an open source relational database management system (RDBMS) that uses Structured Query Language, the most popular language for adding, accessing, and processing data in a database. Because it is open source, anyone can download MySQL and tailor it to their needs in accordance with the general public license. MySQL is noted mainly for its speed, reliability, and flexibility.   Question: Why MySQL is used? MySQL database server is reliable, fast and very easy to use. This software can be downloaded as freeware and can be downloaded from the internet   Question: In

Beginner guide to htaccess - Setup seo friendly url for your website

Here in this tutorial we’ll learn about .htaccess properties and how to setup .htaccess file in our project for custom error pages handling and create seo friendly url. First of all we need to know what is “.htaccess” ? htaccess is short for Hypertext Access, and is a configuration file used by Apache based web servers, When a .htaccess file is placed in a directory which is in turn ‘loaded via the Apache Web Server’, then the .htaccess file is detected and executed by the Apache Web Server software. Create filename “.htaccess” and save it to your project root directory. Note: Before executing this file please make sure that you have successfully enabled mod_rewrite extension in php.ini file Example-1: Create your awkward shaped urls into seo friendly urls using .htaccess Suppose you have these 3 types of urls in your project. http://www.example.com/profile.php?uid=12345 http://www.example.com/profile.php?username=rohit http://www.example.com/search.php?q=delh

Encode and Decode of data URLs using Base64 in PHP

base64_encode and base64_decode: (PHP 4, PHP 5, PHP 7) base64_encode — Encodes data with MIME base64 Syntax: string base64_encode ( string $data ) Encodes the given data with base64.   Example: <?php $str = 'eabhyas.blogspot.com'; echo base64_encode($str); ?> Output:   ZWFiaHlhcy5ibG9nc3BvdC5jb20= (PHP 4, PHP 5, PHP 7) base64_decode — Decodes data encoded with MIME base64 Syntax: string base64_decode ( string $data [, bool $strict = false ] ) Decodes a base64 encoded data . Example: <?php $str = 'ZWFiaHlhcy5ibG9nc3BvdC5jb20='; echo base64_decode($str); ?> Output:   eabhyas.blogspot.com Function : <? function sscb64ende($s,$t=0){     if($t==0){         $v=base64_encode($s);         $v = strtr($v, '+/=', '-_,');     } else {         $v = strtr($s, '-_,', '+/=');         $v=base64_decode($v);     } return $v; } ?>