E-Mail:
Author Avatar

.htaccess Secrets Revealed

Q: I run my own Apache server and I want to restrict certain pages to certain people by blocking certain IPs, but I also want to add error pages. How do I do this?

A: Fortunately, you don’t need some fancy cPanel or Plesk control panel to create your subdomains or error pages, you simply need to take advantage of a little file that Apache (among many other web server applications) allows webmasters to use called .htaccess. These are typically found in the viewable directory of the site you’re working on (typically public_html) and can be placed in each directory that you want special attributes applied to. To create .htaccess files you can simply use your basic text editing program - in fact, it’s preferred.

.htaccess files are ridiculously simple to create for the functions that they serve. The line of the .htaccess file:

Errordocument 404 http://www.domain.com/404.shtml

would direct all traffic that encounters a 404 error within that directory to 404.shtml. You can use all error codes available for this operation, such as 401, 403, and 500.

If you wish to restrict certain sections of your site from certain people according to their IP address, put this line in the .htaccess file for the directory you’re trying to manage:

order allow, deny
allow from all
deny from the.ip.address.here

This code allows everyone except the person with the denied IP address to access the contents of that directory.

Of course, there’s still a lot more than .htaccess can do - it’s really there to run as a mini server configuration file.

For further information regarding .htaccess files, check out Free Webmaster Help’s .htaccess Tutorial. [Jared Hudgins]

What Do You Think?

 


Anti-Spam Image

Want to Start a Blog Here for Free?

Are you an expert in one subject or another? If your goal is to help others and dispense hard-earned information back to the community, stake a claim on your very own Lockergnome blog today! You can write about anything - no matter the topic. Sign-up to start blogging!

Author Avatar
SEO - Mar 6, 2008

Using Differentiators In Keyphrases