Friday, July 17, 2009

.htaccess Tricks and Hacks every webmaster must know


The .htaccess files (Hypertext Access file) is a very powerful configuration tool on Apache web server. The Apache web server has a number of configuration options that are available to the server administrator. The .htaccess is a simple ASCII text file placed in your website root directory. You can create and edit an .htaccess file using a text editor like notepad.

Here on iTechnobuzz.com I have come up with useful tips and hacks to configure your web server.
As a configuration file .htaccess if a very powerful and a slight syntax error can result in a severe malfunction of your server. So to avoid that always try to keep a backup copies of all your files from the server before working with the .htaccess file.


1. Creating a custom error page with .htaccess on a linux apache is a very simple task. Using you a text editor like notepad you create an .htaccess files. Custom error pages give your website an professional look and catch those visitors who reach your website following a back link.

ErrorDocument 401 /error/401.php
ErrorDocument 403 /error/403.php
ErrorDocument 404 /error/404.php
ErrorDocument 500 /error/500.php


2. How to set the timezone on your server

SetEnv TZ America/Houston

3. Block IPs Using htaccess
Sometime you need to block certain IPs from accessing your entire site or directory. Its pretty simple task. All you have to do is inside the .htaccess file is put the following code.

allow from all
deny from 145.186.14.122
deny from 124.15

If you use the whole IP or a part of the IP to block and add the new ones in a new line.
When someone trying to access your site from the banned ip they will get a 403 error access forbidden message.


4. SEO Friendly 301 permanent redirects for bad/old links and moved links

Redirect 301 /d/file.html http://www.htaccesselite.com/r/file.html

5. Set the Email Address for the Server Administrator - Using this code you can specifying the default email address for the server administrator.

ServerSignature EMail
SetEnv SERVER_ADMIN default@domain.com


6. Hotlinking protection with .htaccess is very important because anyone can hot link to your images and eat up all your bandwith of your server. The following code will help you to prevent that.

Options +FollowSymlinks
# Protect Hotlinking
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?domainname\.com/ [nc]
RewriteRule .*\.(gif|jpg|png)$ http://domainname.com/img/hotlink_f_o.png [nc]


7. Block all requests from user agentby creating a perfect .htaccess ban list, you can block all of unwanted user agents that will keep your server load down. Also Check out this interesting thread on webmaster world about the 228 user agents ban list.

## .htaccess Code :: BEGIN
## Block Bad Bots by user-Agent 
SetEnvIfNoCase user-Agent ^FrontPage [NC,OR]
SetEnvIfNoCase user-Agent ^Java.* [NC,OR]
SetEnvIfNoCase user-Agent ^Microsoft.URL [NC,OR]
SetEnvIfNoCase user-Agent ^MSFrontPage [NC,OR]
SetEnvIfNoCase user-Agent ^Offline.Explorer [NC,OR]
SetEnvIfNoCase user-Agent ^[Ww]eb[Bb]andit [NC,OR]
SetEnvIfNoCase user-Agent ^Zeus [NC]

Order Allow,Deny
Allow from all
Deny from env=bad_bot

## .htaccess Code :: END 


8. Redirect everyone to different site except few IP -If you want to redirect all the visitors to a different IP. Also give access to certain few IPs. You can use the code below

ErrorDocument 403 http://www.youdomain.com
Order deny,allow
Deny from all
Allow from 124.34.48.165
Allow from 102.54.68.123


9. Don’t want to display download request - Usually when you try to download something from a web server you get a request asking whether you want to save the file or open it.
To avoid that you can use the below code on your .htaccess file.


AddType application/octet-stream .pdf
AddType application/octet-stream .zip
AddType application/octet-stream .mov


10. Change the file type - Make any file be a certain kind of file type Makes image.jpg, index.html, default.cgi all act as php


ForceType application/x-httpd-php
SetHandler application/x-httpd-php
 


11. Block access to your .htaccess file - By adding he following code to your htaccess file will prevent attempts to access your htaccess file. This extra layer of security protects your htaccess file by displaying a 403 error message on the browser.

# secure htaccess file

 order allow,deny
 deny from all


12. Protect access to certain specific file on your server - this can be done by adding the below mentioned code. For example you want to block with the file name default.jpg This will prevent the viewing of this file.

# prevent access of a certain file

 order allow,deny
 deny from all


13. Prevent access to unauthorized browsing - Protecting specific directory browsing can be done by intructing the server to serve a Forbidden and Authorization required message while anyone requests to view that particular directory. Usually if you site doesn’t have a default index page any files within that directory is accessible to the visitors. To avoid that use the following code in the .htaccess file.

# disable directory browsing
Options All -Indexes


14. Setting the default page - You can set the default page of a directory to any page you like. For example in this code the default page is set as about.html instead of index.html

# serve alternate default index page
DirectoryIndex about.html


15. Password protect your directories and files - You can create authentication for certain files and directories from being access. The code has examples of both password protection for a single file and password protection for a entire directory.

# to protect a file

AuthType Basic
AuthName “Prompt”
AuthUserFile /home/path/.htpasswd
Require valid-user


# password-protect a directory
resides
AuthType basic
AuthName “This directory is protected”
AuthUserFile /home/path/.htpasswd
AuthGroupFile /dev/null
Require valid-user


16. Redirect an old domain to a new domain Using htaccess file you can redirect a old domain name to a new domain by adding the following code into the htaccess file. Basically what it does is it will remap the old domain to the new one.

# redirect from old domain to new domain
RewriteEngine On
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,L]


As htaccess files are very powerful, even a slightest syntax error can cause sever malfunction of your server. So it is crucial to take the backup copies of everything before you try the hacks and tricks on your hypertext access files. Post your thoughts with a comment.

Hope You love reading@ gadgetsnalll, stay tuned with us for more.

Firefox 3.5.1 Security and Stability update now available

In the previous post of mine, I had updated you about the critical security vulnerability in Firefox 3.5 . In response to this, Firefox 3.5.1 update is now available.The updated setup is now available on Mozilla Website.If you are using Firefox 3.5 allready, you can update your Firefox to v3.5.1 simply by going through

Help >> Check for updates..

A new window like the in the screenshot will pop out and all you need to do, is to click on Update Firefox.

A critical security vulnerability was discovered in Firefox3.5, and this update fix that vulnerability on its own. If the update is still not available for you, you can fix this problem manually by going through the following steps:
Enter about:config in the location bar to access advanced preferences.
Look for javascript.options.jit.content and double click it to set it to false.

If you had allready applied the above steps, and this update is available for you, then you need to undo the manual changes you did before. To do this, simply follow the previous 2 steps and double click javascript.options.jit.content and set it to true. Now, you are ready to update your Firefox to v3.5.1

If you does not get the update option in your Firefox, you can get it from their US website by clicking here.

The Mozilla team is working on decreasing the start-up time of Firefox, which i guess will be provided in next update at the end of this month.


Google Chrome operating system will be out in 2010


In a post of Google Blog, Google’s Sundar Pichai announced “However, the operating systems that browsers run on were designed in an era where there was no web. So today, we’re announcing a new project that’s a natural extension of Google Chrome — the Google Chrome Operating System. It’s our attempt to re-think what operating systems should be.”

Yup, its all true. After the great success of Google Chrome web browser, google is competing with microsoft with the still to release Google Chrome Operating System for netbooks. Google chrome will be an open source, light weight OS specially getting developed for netbooks. It will be out in market in second half of 201o.

With this step, microsoft is surely not impressed, as they got some new competitors for manufactures companies, which could reduce their prices by providing some open source free OS with their netbooks.

The blog says that “Speed, simplicity and security are the key aspects of Google Chrome OS. We’re designing the OS to be fast and lightweight, to start up and get you onto the web in a few seconds.”

Google is trying to bring this lightweight OS in the second half of next year in the market. It is allready working with multiple OEMs so that it could be out asap. Google chrome OS will run on both x86 as well as ARM chips. And yup, it wwill be totally different from Android. The blog says that, “Google Chrome OS is a new project, separate from Android. Android was designed from the beginning to work across a variety of devices from phones to set-top boxes to netbooks.”

Gadgetsnall is excited with the news and we are waiting for the release of the same OS. Lets see, how fast can google make out of this. Tell us, how you feel about the same. Use our comment box.

Top 5 graphics cards till nov 2008

This Christmas are you thinking about upgrading your PC, or build a new rig based on Nehalem, one of the most fundamentally important choices you make will be the graphics card.

Choose wisely, and you’ll have years of high definition gaming ahead of you.

Choose badly and you’ll be back to the shops by June.

But which offer the best performance in their category, and which are good value buys? Here’s www.iTechnoBuzz.com ’s pick of the five best:




Asus Radeon HD4870 X2 £400 www.asus.com

The title of ‘Fastest graphics card in the world’ is a bit of a misnomer, really. The X2 suffix indicates that this AMD card actually has two processors on board, which means it works in the same way as a CrossFire X or SLI setup, just without taking up an extra PCI-E slot.

On the one hand, it delivers earth-shattering performance that can’t be rivalled by any one GPU. On the other, it raises concerns about driver support. The latest driver from AMD seems to be working well in most games, but there’s no guarantee that all will be well in the big Christmas line up. The dual processors also make it blisteringly hot and power hungry to run.
Still, if you want the best, this is it. If you don’t have a 30-inch monitor that requires the kind of pixel power it puts out, though, you might want to look elsewhere.



Sapphire HD4850 X2 £317, www.sapphiretech.com

A similar principle has been applied here. Two of AMD’s HD4850 chips have been soldered onto a single circuit board and attached to a ruddy great heatsink for ‘CrossFire on one card’.

Performance is reported to be more or less the same as Nvidia’s top ranking GeForce GTX280, and having seen HD4850s in CrossFire configurations before, iTechnoBuzz is not surprised in the least.

Again, though, any multi-GPU configuration gives us cause for concern when it comes to driver support. There’s nothing worse than booting up your favourite game on its day of release and having to drop the resolution because you can only run one GPU.

On the other hand, it does look like it’s a few pounds cheaper than a GTX 280, so is a very tempting one for loyal AMD fans.




BFG GTX 280 H2OC £446 www.bfgtechnologies.com

The glory of ‘Fastest single chip’ then, goes to Nvidia’s GeForce GTX 280. Armed with 240 stream processors and an enormous 1GB of memory on a 512-bit bus, it’s a huge card with bigger aspirations.

That’s not enough for everyone, though. This BFG model is overclocked by almost a fifth to 680MHz and kitted out with a bespoke water-cooling block. It adds about £130 to the price of a regular GTX 280, but will certainly find a home in a specialist water-cooled system. The rest of us would be better off buying a vanilla version for the reduced price.



Gigabyte GeForce GTX 260 OC approx £220, www.giga-byte.co.uk

The problem with the highest end cards is that game engines really aren’t keeping up with graphics hardware. Unless you’re running a 24-inch monitor or above with a native resolution of 1,920×1,200 or higher, you really don’t need to spend a fortune on a top-end videocard. You’ll just be pumping out more frames than the eye can see.

Move down to the £200 range, and Nvidia’s newest GPU tops the tables. There are two versions of the GTX 260 – one with 192 stream processors on board and one with 216 – and they can be hard to tell apart. This is one of the latter, and the extra power it gains over the lower end model is enough to make it almost as fast as a GTX 280 for two thirds of the price.





HIS Radeon HD4850 IceQ 4 £131, www.hisdigital.com

The real action, though, is at this sort of price level. That’s what most people spend, and that’s where there’s a glut of cards all with similar levels of performance. There’s the Radeon HD4830, for example, or the GeForce 9800GTX to choose from.

Our current favourite entry into this category at the moment is this overclocked version of AMD’s HD4850 – itself a very good card. HIS has fitted an almost silent heatsink with a very capable fan. This means it can be shipped running at higher clockspeeds than a stock version of the card, and the result just edges it to the top of the table for hardware at this price.