bpresent
Webmaster Tutorial Menu
Tutorial Home
Life before .htaccess
You have to start somewhere
Becoming a Webmaster
The steep learning curve
What to look for in books
How many hats?
Technical Job Description
Linux or Microsoft?
Standard web stuff
Basic HTML
Frames and/or Flash?
Site submission
Negotiating Links
Robots.txt
Validating your HTML
Web safe fonts
Web safe colours
Different screen & monitor sizes
Cascading Style Sheets (CSS)
Javascript
'Nix specific stuff
Choosing a 'Nix hosting company
Web Logs Demystified
Web Log Status codes
Limitations of robots.txt (and the power of .htaccess)
Conclusion
_
cost  effective,   fast  loading,   lightweight,   high  return  websites
_
_

The power of .htaccess

I had noticed on a couple of sites that I visited that if I typed in an invalid address I was sent to a special "404 page not found" page. At the time, I thought this was pretty cool so I asked around about how to do it and was told about the ErrorDocument statement that I could put into my "htaccess file". All goobledee-gook to me so I did little or no reading and just copied the examples, made a few tweaks, put it into my root directory and all worked fine.
I later found out that customised 404s are not necessarily such a good idea as every time a malicious robot comes looking for an unsecure email form etc I will be using up bandwidth - especially if I put a fancy friendly logo on the 404 page. All was not lost though...

mod_rewrite

Having already found out that the robots.txt was useless in detering these nasty robots, and having realised that I really wanted to keep these guys away as best I could, I needed to find out more about how to use .htaccess for this. These robots also "harvest" email addresses displayed on websites and add them to their spam lists.
I didn't know which robots were good and which were simply stealing email addresses etc so I searched WebmasterWorld and found this list of robots to avoid which I subsequently modified. (I quickly learnt to not trust everything I read in WebmasterWorld and also - we all have different preferences).
Also, new robots appear all the time so the logs and the posts need to be watched and forums reviewed in order to keep up.
The above robots post in WebmasterWorld.com introduced me to the world of mod_rewrite.
I've heard the guy who invented htaccess described as a genius. Sometimes, I think people describe other people as genii when they have come to the point where they have no idea what the other person is talking about ... and I have to admit, I find htacess very challenging at times. Even the so called gurus don't seem to know how to fix it sometimes (and they are just as prone to making those fiddly little mistakes that take weeks to find).
_
_
_
In order to use mod_rewrite fully I had to find out about Regular Expressions (which I've since found out is really useful in PHP code etc). I also found this RegEx tutorial useful.

301 redirects / 410 redirects

Anyway, htaccess with mod_rewrite is really handy and, in the simplest forms, is excellent for simple tasks like keeping the bots at bay and telling search index robots that a page has moved permanently (301) or gone permanently (410) and is not too difficult to master for this task.

Sub.domains and hosting account sharing

Depending on your hosting supplier (or if you have a dedicated $erver) you may be able to use mod_rewrite to split your account into sub domains or even unique domains all within the one account. For example, my hosting provider allows me as many domains as I want, all pointed to the same _public_html so long as they are part of my business / hobby (ie. I cannot resell within my own account). Of course they all add up into the same storage and traffic limits so there is a limit.
In summary, mod_rewrite (within an .htaccess file) can be incredibly handy, is streets ahead of anything you find on Microsoft servers and is free (or at least included in the very reasonable costs of 'nix hosting on apache servers).
 
[Content of this page last reviewed: 05-Oct-2004]
_
_ _
copyright © 2001-2007 bpresent
Terms of Use, Privacy Policy, Copyright and Trade Marks
Sydney +61 438 726 669