Taking Control of Your Web Site
You may have more control over your Web site than you think. Through the creation and manipulation of an “.htacess” file, you can control who can access your Web site and what they see when an error message is generated. Here are some basics you can use to take more control over your Web site.You may have more control over your Web site than you think. Through the creation and manipulation of an “.htacess” file, you can control who can access your Web site and what they see when an error message is generated. Here are some basics you can use to take more control over your Web site.
Web girls. They give me chills. I have a secret crush on Nina but, hey, don’t we all? As I check my site stats daily and calculate how many pizzas I can buy with my modest day’s earnings, I fantasize about the bucks I could make if my own dear wife would get behind a Web cam from time to time! She has a reason for not doing it, though, and I’ll admit it’s very legit. Mommy and daddy would have a cow if they saw their little girl on display for the whole world. It occurs to me, however, that there is a way to diminish the chance of family and friends stumbling across your Web cam site (or any other site). I’m referring to the trusted .htaccess file. This wonder of modern Web design technique has all kinds of advantages, and even though it won’t convince my own sweety patootie to broadcast her bod to the world, others may find the multi-functionality of it useful.
Newbies may be asking what a .htaccess file is. The .htaccess file is an ASCII text document that can be placed in any directory on your site. Not only can it be used to control access to files and directories, it can also be used to customize some server operations. A .htaccess file can be created in any word processor, but because it must be saved as text only, Notepad is recommended When uploading or editing your .htaccess file, be sure to use ASCII mode.
KEEP OUT!
There are a variety of functions that you can control using .htaccess. The most common, of course, is used when setting up password protected areas of your site. In our case, these are the “members only” pages. In the example above, this would prevent users from viewing your Web site (unless they paid, of course!) but does little to prevent folks from finding your Web site (like family and friends). However, setting up this .htaccess function is a breeze!
To deny user access to your entire site, just add this into you .htaccess code:
<Limit GET>
order allow,deny
deny from XXX.XX.XX.
deny from XXX.XXX.XXX.XXX
allow from all
</Limit>
Using this example, the .htaccess file will effectively block access to your site to anyone who is surfing in from an IP address beginning with XXX.XX.XX and from the specific IP address XXX.XXX.XXX.XXX. By specifying only part of an IP address, and ending the partial IP address with a period, all sub-addresses coming from the specified IP address block will also be blocked.
CONTROLLING ERROR MESSAGES
But the .htaccess file does so much more. If you’re sick of the bland error messages that appear when a dead page is reached on your site, you can use the .htaccess file to create customized error messages.
Add the following to the .htaccess file:
ErrorDocument 404 /notfound.html
After “ErrorDocument” type in the error code, space, and then the path and filename of the .html file you would like to be displayed when the specified error is generated. For your convenience, here is a list of common error codes:
200 OK
206 Partial content
302 Document found elsewhere
304 Not modified since last retrieval
400 Bad request
403 Access forbidden
404 Document not found
408 Request timeout
500 Internal server error
Using the codes above, your error section of the .htaccess file will look like this:
ErrorDocument 400 /notfound.html
ErrorDocument 403 /notfound.html
ErrorDocument 404 /notfound.html
ErrorDocument 500 /notfound.html
The final .htaccess function I want to cover is a nifty little trick that prevents others from hot-linking images from your site. Time to bust those nefarious bandwidth stealers! Put the following into the .htaccess file:
# Rewrite Rule for images
RewriteCond %{HTTP_REFERER} *URL of page accessing your domain*
RewriteRule ^(.*)$ http://*same as above URL*
Now, replace the *URL of page accessing your domain* above with the domain name and path of the page that is referring to your domain.
The RewriteCond directive ensures that if the {HTTP_REFERER} matches the URL that follows, then the RewriteRule directive will be used. The RewriteRule directive will redirect any reference back to the referring Web page. It sounds complicated, but really isn’t.
Using the above detailed .htaccess functions, you can now install a certain level of privacy on your sites and thwart the evil bandwidth bandits. Like all things, results may vary, but these will work in most cases. Good luck!
J. Edwards is a senior writer for The ADULTWEBMASTER Magazine.