Prevent Directory Listing using .htaccess

What is directory listing ?

As we know, most of the website contains “images” folder inside the root folder. If we type “” in the browser and it shows the listing of the files in the browser like the picture below which means that directory listing is allowed on that web server. It’s better not to show the files inside the directory of the web sever for the security purpose.

7 Useful SEO tips for WordPress Blog

Yesterday Luqmaan of emailed me and asked about the secret of traffic of my blog. I’m very happy with the way traffic is growing in this blog. I’ve started this blog in this domain from 4th of Jan 2008. All the other old posts are imported from my old blog to few difficulties in, I’ve decieded to move my blog to WordPress. And in less than two months, Alexa ranking of this blog is 253,907 which seems really surprising for Luqmaan.

Email address validation in PHP

Well you’ve been asking why this person has posted the same stuff which you can find easily in google. Ya you are right you can get lots of scripts but many of them are not useful for me so far. They just validate the email like “” but they didn’t validate the email address like “” or even the address like ““.

Hide .php extension with url rewriting using .htaccess

Last time I’ve written an article about hiding php file extension where I’ve showed you how you can use .html or .asp extension of file instead of .php extension. But there was one flaw in that technique you have had to change the file extension explicitly but in this post I’m going to show you how to rewrite the URL instead of renaming the file extension Using this technique you will see product.html in the address bar of the browser but the actual file name remains product.php and you don’t need to rename the file extension. Furthermore you can rewrite the URL like product.php?id=5 to product-5.html.

Absolute path and Relative path file inclusion in PHP

I think you guyz must be aware of absolute path and relative path in PHP. If you do not know anything about it then let me explain you about absolute path and relative path in the server with the example using include() function of PHP. You can see the example below, I’ve included the same files in PHP but the same file is included in two different manner.

  include("/home/example/public_html/config.php"); //absolute path
  include("config.php"); //relative path

How to solve the problem of retrieving same value by Ajax – Browser Cache Problem

You might have faced the problem of the getting same response on the consecutive request to a PHP file from Ajax. Well, what happens when making repeated GET requests to the same URL can often lead to the response coming not from the server but from the browser cache. This problem mainly occurs while using in internet explorer.

Now let’s look at the various methods to solve this problem :

How to run a php file(script) automatically in a certain interval – Using Cron job

In your project you might have to run a function or script (.php) file automatically for a various reasons like automatic sending email on birthday or automatically close a auction when the end_time is reached. What to do in that situation? .To do these things automatically, you must have a php file which must contains the code and these files should be called automatically at certain certain time. So how to do that? The answer is Cron Job. Cron job are the cron tab command found in the UNIX or Linux system.

Now let’s see how can we call the file automatically at certain duration. Let’s suppose the duration is one hour, now I’ll show you how to setup the the cron-job of every one hour to run a PHP file automatically in the Cpanel of your website.

Getting real IP address in PHP

Are you using $_SERVER[‘REMOTE_ADDR’] to find the the client’s IP address in PHP? Well dude, you might be amazed to know that it may not return the true IP address of the client at all time. If your client is connected to the Internet through Proxy Server then $_SERVER[‘REMOTE_ADDR’] in PHP just returns the the IP address of the proxy server not of the client’s machine. So here is a simple function in PHP to find the real IP address of the client’s machine. There are extra Server variable which might be available to determine the exact IP address of the client’s machine in PHP, they are HTTP_CLIENT_IP and HTTP_X_FORWARDED_FOR.