.htaccess file guide
By David Callan
You may have already come across the .htaccess file while on www.akamarketing.com,
we used it in the article Custom
error pages to enable you to set up custom error pages so visitors
will be taken to a custom error page on your site and not your hosts error
page or what's even worse the default page not found type of error page.
Using the .htacces file for custom error pages is however only the tip
of the iceberg, the file can be used in a lot more ways but before we
go into the nitty gritty of what can be done with it lets first explain
what it is and where it is found.
The .htaccess file is a file that enables you to control how your hosts
server deals with your website and webpages. This usually involves adding
lines of code to the file or editing lines already present. You should
be aware that editing the .htaccess file can seriously alter your website
and webpages so always make a copy of the original and store it in a safe
place so if anything does go wrong you can easily revert back to the old
file.
As for the location of the file, the file is usually found in the root
directory of your website, if it's not there don't worry as it can be
easily created. Simply open a blank text document and call it .htaccess
and then upload it. Even if you use an online manager instead of an FTP
program the process is still similar, just select new file and call it
.htaccess.
You can if you want upload two or more different .htaccess files to two
or more different directories, each file will affect the directory it's
in but will not overwrite .htaccess files that are in other directories.
This means that a .htaccess file will affect all sub-directories unless
that sub-directory has its own .htaccess file. This property of .htaccess
files is useful for example if you wanted to set a directory's default
page to something other than index.html and have different default pages
for all sub-directories too, but more on that later.
Now we'll go through some of the more useful things that can be done
with the .htaccess file, we'll also tell you how to do these things. Well
first we have the custom error page feature, if you want to learn about
this check out my article entitled Custom
error pages.
File protection is also another use of the .htaccess file. This enables
you to protect certain directories and files by way of a username and
password. We used to use it here at www.akamarketing.com for our free
ebook directory which in the past required that you be a member of the
AKA Marketing webmaster community before being given access to the directory.
It involves placing a small file in the directory you want to protect.
It's very easy to implement, here's how it's done. Before we start you
need to be able to Telnet your site. If Telnet is not available then you
should look into a CGI script to protect your files.
This is what should be in the .htaccess file
AuthUserFile /usr/www/dirname/.htpasswd
AuthGroupFile /dev/null
AuthName "The ebook directory"
AuthType Basic
<Limit GET POST>
require valid-user
</Limit>
You only need to change two of the above lines. Change the AuthUserFile
line so that the UNIX PATH matches that of your system. This is where
the password file will reside.
AuthName is the name of the thing your protecting, the popup box in this
case would say 'Enter your password for The ebook directory', you of course
should change this to something which correspondents to the section of
your site which your trying to protect.
Using Telnet go to the directory your AuthUserFile path is pointing to
and type 'htpasswd -c .htpasswd username' to create the file
and add "username" as the first user. The program will prompt
you for a password then verify it by asking again. You'll not see the
password when entering it so be extra careful.
htpasswd -c .htpasswd username is only used to create the initial .htpasswd
file, after the first username and password is entered you've to type
in 'htpasswd .htpasswd Jack' leaving out the '-c'. The above
code would add the username Jack to your .htpasswd file and again you'll
be asked to input a password.
To delete usernames you'd simply open up the .htpasswd file and remove
the appropriate lines.
If you want to discontinue the protection of a directory simply type
the command 'rm .htaccess'
If you haven't got a Telnet client you
can get the puTTy client for free here!
The next thing we can do with the .htaccess file is change the default
page from index.html to one of your choosing.
By default most web servers will load index.html as the default page,
some webmasters will not want this on all occasions. I myself wanted a
CGI script as the default page for one of my directories to enable a short
address to go in my signature file.
I changed the default file in the sub-directory 'webmaster-forums' to
ikonboard.cgi so the forum address would be akamarketing.com/webmaster-forums
and not akamarketing.com/
webmaster-forums/ikonboard.cgi which is longer and harder to remember.
Here's how it's done.
Simply insert the line
DirectoryIndex ikonboard.cgi index.html
I placed this code in the .htaccess file in my webmaster-forums sub-directory,
this means that when the webmaster-forums folder is requested the server
will load ikonboard.cgi first and if that's not found it will load index.html.
I left my main directory unchanged so the root directory's default page
is still index.html. You of course would change ikonboard.cgi to the file
you want to load first, maybe index.cgi, index.php or home.html, basically
any file a browser can handle. That was easy wasn't it?
Well that's it then. As you can see the .htaccess can be set up to do
some very useful things for the webmaster. We've covered three of these
in this article, these where custom errors, password protection and setting
the default file to something other than index.html.
There are however other uses of the .htaccess file including using it
to restrict access from certain domains/IP's and using it to prevent people
from stealing your bandwidth, but to be quite honest I don't really understand
these two myself so I'm not going to try and teach you something I don't
understand.
If you want to learn more about the .htaccess file do a search for it
on Google, you'll be returned with lots of good sites you can check out.
About the author
Article by David Callan. David is an Internet marketing professional
and webmaster of http://www.akamarketing.com/webmaster-forums/.
Visit his webmaster forums for the latest discussions on search engines,
website authoring and Internet marketing related issues and topics. |
» Change
your mind about an eBay bid?
We have all made choices in life that two seconds later
we know we should take back. Especially when there is money involved
this can become a problem.
» A
simple way to create 7 effective autoresponder messages
Email is the Net's most powerful marketing tool. And autoresponders
are the best idea yet for marketing with email.
» 7
ways to drive laser-targeted traffic to your website
Getting people who matter to see one’s website
is a difficult undertaking if he tries to consider the fact that
there are rivals everywhere waiting to pin him down.
» Website
valuation: Why standard website pricing methods will emerge
The market of buying and selling developed websites is
becoming more and more liquid each day.
» One
way links are better than reciprocal links
You probably know by now that where your website ranks in
the search engine rankings dramatically affects how many visitors you
have to your site. Did you also know that you can change where your
site is ranked by being proactive and getting as many one way links
to your site as possible?
» How
to make visitors stay at your website
The very first thing which you should provide the visitors
with is some free interesting reading material.
» How
to make your visitors click your ads
Here is a simple solution; Convert your banner advertisement
to look like a text advertisement!
» Offline
advertising should be a part of your online strategy
Day by day, online business has become more & more
complicated and competitive.
» How
to sell traffic
Selling the traffic arriving at your site is a good method
to increase profits from your portal.
» Make
money from online auctions
Online auctions have the best benefit of a vast platform.
Your product is viewed by loads of people & hence there is
more possibility of finding a suitable bidder.
» Groupware
explained in easy terms
Groupware is a term used frequently to describe collaborative
software. Groupware is application software that integrates work
on a single project by several concurrent users at separated random
workstations.
» Timely
back up can save you from disasters
Few things which people often back up are e-mail addresses,
bank records, photographs, personal records, software’s,
music etc.
» Why
should one go for autoresponders
Autoresponders are programs which get automatically
executed in particular situations.
» Become
your own boss - Start your own online business today
A survey conducted by SBA states that two third of new
business survives at least two year and about forty four percent
survives at least four year.
» Express
your thoughts - Creating your own blog!
What exactly is a blog? Technically speaking it is a
journal or a newsletter which is regularly updated and can be used
by any one.
» Pop-up
ads - To be or not to be?
According to a study conducted by the Bunnyfoot University, “The
Efficacy of Pop-ups and the Resulting Effect on Brands” Internet
users feel harangues and harassed by pop-up ads.
» Why
content is king on the Internet
The advantages that Internet holds over the rest of
the other communication mediums should not wasted because of
the inability to find a comprehensive plan that will bind all
these faculties together.
» 10
niche marketing tips
In our increasingly driven consumer economies, the average
customer is bombarded by choices. With increased saturation of the
market, companies look towards niche marketing to search new, ever-evolving
and sophisticated consumers.
» Using
free traffic exchange
These days internet has emerged as both, a market and
hub for marketing. Unlike the ‘brick and mortar’ world
where large manufacturers manage to squeeze out the market bases
of smaller companies, the internet provides haven like the free
traffic exchange.
» Ten
ways to drive traffic to your website
Developing a web site and then letting it grow is
like planting a tree and then nurturing it.
» Marketing
through keyword articles
One of the most effective tools of Internet marketing
is the use of keyword articles.
» Want
to make money online? Market a service to businesses
Don walked across the street from his house to mine to
announce he had finally retired. "But I'm not ready for the
golf course," he said. "I want to make a living on the
Internet. What can I sell?"
» Web
site design mistakes - Database parameters in URLs
Creating a web site takes thought, planning and execution.
Unfortunately, many designs are dead in the water before they are
even published as far as search engine optimization is concerned.
Whatever you do, avoid these critical mistakes.
» Alexa
Toolbar - The ultimate internet tool
There are numerous tools available on the Internet to
assist online businesses. A valuable tool that you should use is
the Alexa Toolbar. Even better, this tool is free.
» Web
site design mistakes
Some wise human once said "Learn from the mistakes
of others. There isn't nearly enough time to make them all yourself."
Hence this article. Here are five of the most annoying and common
web design mistakes.
» Abandonment
- Why visitors don't turn into customers
Every good Internet business understands the value of
conversions versus hits received. Far too often, businesses become
fixated on the hits they are receiving instead of monitoring their
hit to sale conversion rate.
» Creative
search engine optimization - A case study
Search engine optimization this and search engine optimization
that. You read and hear about it all day, but what about your site?
|
|
Tools & services to enhance your online
business |
|
» Site
Build It!
Over 100,000 small businesses of all kinds outperform
larger, well-financed competitors. Read about this all-in-one site-building-hosting-marketing
system of tools that delivers results.
» Secrets
To Their Success
Take a private tour of two "Mom & Pop"
web sites every month that earn $100,000+ a year... and discover
the exact step-by-step strategies they have personally used to generate
these massive profits. |
|
|