Monthly Archives: October 2010

How to include multiple js file in one js file?

To include multiple js files in page is bad in terms of http request. Yslow Yahoo! tool can give you bad grade. Grade F on making more HTTP requests.
Apart from that page loading time increases and page does not looks clean.

Combined files are a way to reduce the number of HTTP requests by combining all scripts into a single script, and similarly combining all CSS into a single stylesheet.

Including multiple .js file in one external file has several advantages.
1. Less HTTP request.
2. If cashing is on page lode faster.
3. Page looks clean.

Use this code to add as much as files as you want.


How to add www in url through .htaccess?

Recently I was working on a project and SEO team requested to add WWW forcefully in project URL. I asked why, they said.
“Must have www in your URL! Google Like it.”
So here is .htaccess snippet to force a url with WWW
When you will type it will automatically become

This is how I did in this site. I am telling you one .htaccess secret. You can experience here only.


How to add and disable ETags through .htaccess?

What is ETag?
An ETag, or entity tag, is part of HTTP and it provides a unique identifier for the resource being supplied.

This identifier can then be used to validate if it resource has been modified or
Browser requests can use an etag and an if-match header to check whether a resource has been modified since it was served, providing an efficient caching facility that relies on content rather than on timeouts.

Use this code to setup ETags on your server, using following htaccess.

Sometimes developer want to be disable ETags from headers. To disable ETags, make sure to include following snippet in your .htaccess file.


How to use .htaccess for permanent redirect 301?

If you are making search engine friendly URL from pages which are using query string (i.e. ) and pages which are indexed in search engines or if you are rewriting your website with new urls then you need permanent redirect 301!!

Let me tell you what happens here. If you remove a page which is already in Google it will generate error and that is not good for your site.
So .htaccess for permanent redirect will save life! Just redirect old to new url and Google will like your site this is good practice in terms of SEO too.

This one line PHP code is worth to add in .htaccess file of your root directory without loosing search engine ranking in Google and Others.


How to prevent hot linking using .htaccess?

Don’t let your users your photo steel! If you have very good photo or even not good! and want to prevent your files using php technology, such as jpg, gif, bmp, png etc.

You can just put this code in root directory of .htaccess file of your php project and it won’t let others site use you files directly and it will save your bandwidth. This is the main purpose of blocking hotlinking using .htaccess in php.


How to upload big file using .htaccess?

You can upload big file yes it is possible without applet and other third party lib!
Simply put these standard configuration values and they will overwrite php.ini setting, which does not let you upload big file in your server.


How to force http to https through .htaccess?

In order to force https:// in payment and other secure pages even if your customer try to access http:// or they forget. You can use .htaccess file and simple code.

Example –
I had created a page
I want my visitor to access
Here is code which will force them to redirect to https://


How to explode a string and create hyperlink?

Here is very easy code to create Tagged List with hyperlink.
I have found several events where we have to create dynamic URL with Tagged text.
I have used very simple approach. Just Exploded sting and replaced space with “-”
You can use PHP function preg_replace() or str_replace() then used here-docs for creating hyperlink.
Instead of Echo Hear Docs is much better solution.
And at last removed the last Comma, and return your comma separated Dynamic links.