Practical eCommerce

Manage Subscriptions · Subscribe Now · F.A.Q.'s

HOME · Saturday, July 5, 2008

Development & Programming

Get To Know Your .htaccess File

By: Brian Getting
Comments: 5

A valuable tool many web developers either don't understand or aren't aware of is the .htaccess file. The file is available only to websites hosted on servers running the Apache web server, which is the overwhelming majority of hosting servers. An .htaccess file is a small, plain-text file residing in any directory of a website, and can contain directives to adjust the way the Apache web server reacts. The configuration changes apply to the directory that the .htaccess file is saved in, and to any directories that it might contain. To better understand them, let's take a look at some of the things web developers can do using .htaccess files.

Probably one of the most common directives in an .htaccess file is one preventing "directory indexes." A directory index occurs when a website visitor types in the URL of a directory on a website, and that directory also has no index file. Without anything to send out, the Apache web server will then send the visitor an index, or itemized listing, of all the files in that directory. In some cases, this can represent a security risk, and is generally just bad form. A developer can put a simple directive into a text file that will stop that from happening. Simply save the file as ".htaccess" and place it in the directory of choice, and Apache will no longer allow visitors to view a directory index.

Another common use of .htaccess files is to define custom error pages the web server should send out if it come across an error. All of us have seen that generic “Page Not Found” error, which is sent by Apache when a request is made for a file that cannot be found on the server. Again, it is often ideal to have a custom error page sent to visitors. Just like with directory indexes, there are simple directives to put in an .htaccess file that will serve out a custom page for each error defined. In this case, the .htaccess file should be in the root directory of the website, so that the directives apply to the entire site.

While these are just a couple of common examples, the greater lesson is that every web developer should be intimately familiar with .htaccess files and what they can do with them.

AdvertisementInfopia

Blinklist | Del.icio.us | Furl | Ma.gnolia | Newsvine | Spurl | Reddit | Technorati

Published on Wednesday, November 01, 2006

Comments:

Great article! Just thought I would let you know...

Posted by: Albert Bell
Wednesday, January 03, 2007

Nice but incomplete info. How about some pointers where a budding developer or site-owners themselves can get some of the goodies you can put in the .htaccess file? This article is only saying it's possible, but does not even hint at where to get the info you REALLY need... Suppose one can find out, but would've been nice to have a little more substantive info in this article.

Posted by: rkuipers_jm@yahoo.com
Tuesday, May 15, 2007

I would also like to get some practical example I can use.

Posted by: Craig
Tuesday, May 15, 2007

.htaccess is very powerful. I use it to password protect parts of my web site as well as the examples used in the article. Here's some information to fill in the blanks left by the article.

For those interested in learning the technical side of .htaccess, visit this great tutorial which I use as a reference.

http://www.freewebmasterhelp.com/tutorials/htaccess/

Apache also has a useful HowTo that can be found at:

http://httpd.apache.org/docs/1.3/howto/htaccess.html

Posted by: DaveW
Wednesday, May 16, 2007

Here's additional information on .htaccess:

http://apache-server.com/tutorials/ATusing-htaccess.html

Posted by: patocrow
Wednesday, May 16, 2007

↑ Back to Top

Leave a comment:

Please enter the following security code exactly as it appears.


Comments are stripped of HTML code upon submission. All comments are submitted for approval prior to being published. Please allow up to 24 hours for the approval process to take place. Practical eCommerce reserves the right to remove any comment at any time for any reason.

 


Related Articles

Articles at Practical eCommerce related to Get To Know Your .htaccess File:

Related Podcasts

Podcasts at Practical eCommerce related to Get To Know Your .htaccess File:

RSS 2.0 Feeds

Atom 1.0 Feeds

Technorati Tags

Ecommerce Articles

Browse All Articles
Browse our complete archive of ecommerce articles.
Accounting, Management & Legal
Ecommerce articles related to managing a small business including ecommerce accounting, business strategy and legal considerations.
Conversion & Usability
Online business articles about converting web site visitors into customers and how to gauge and improve your business website's usability.
Development & Programming
Articles to help designers, developers and programmers create successful, search engine friendly ecommerce websites and improve existing ones.
Hosting, Infrastructure & Software
Articles for ecommerce businesses about ecommerce web hosting, business infrastructure, business strategy and helpful ecommerce & small business software.
Interviews & Profiles
Interviews with prominent ecommerce business personalities and profiles of successful online businesses.
Inventory & Shipping
Ecommerce articles about inventory management, ecommerce order fulfillment and product shipping considerations.
Marketing & Revenue Growth
Articles relating to online marketing, email marketing and using the Internet to growing your business.
Search Engine Optimization
Search engine optimization articles for ecommerce business owners, strategists, marketers and developers.
Shopping Carts & Online Payments
Articles covering ecommerce shopping cart platforms and options for choosing an online payment gateway.
Training & Education
Tutorials and articles providing training and education for ecommerce business owners and developers of ecommerce websites.

Search Articles

Ecommerce Community

Ecommerce Blogs
Read our blogs about ecommerce topics written by industry professionals.
Community Forum
Connect with other ecommerce professionals to trade advice and answers in our community forum.
Podcasts
Check out our ecommerce podcasts covering topics ranging from interviews to tutorials.
RSS Content Feeds
Subscribe to our RSS feeds and have fresh ecommerce content delivered to you.

Ecommerce Resources

Free Email Newsletter
Sign up for Ecommerce Notes, our free email newsletter for ecommerce business owners and developers.
Ecommerce Directory
Browse our directory of ecommerce products and services, or submit your own listing in our directory.
Ecommerce Glossary
Familiarize yourself with terminology or submit terms to help others with our Ecommerce Glossary.
Events Calendar
Find out about upcoming ecommerce events or invite other ecommerce professionals by posting your own event.
Press Releases
Browse ecommerce related press releases and post your own press release for distribution.
Ecommerce Store & Back Issues
Pick up back issues of Practical eCommerce magazine along with other merchandise from Practical Ecommerce

About Practical eCommerce

Frequently Asked Questions
Look at frequently asked questions regarded using our website, subscribing to our magazine and more.
Advertising Information
Information about advertising in Practical eCommerce magazine, on our website, or in our email newsletters.
Editorial Sharing
Learn about options for sharing our content with your visitors, customers or employees.
About Us
Learn more about Practical Ecommerce magazine and meet our staff.
Contact Us
Contact Practical Ecommerce at any time for more information. We'd love to hear from you.
AdvertisementEndiciaArial SoftwareSlackBarshinger - Online Market World

Copyright 2007 Confluence Distribution, Inc. and Practical eCommerce.
All Rights Reserved.

Privacy PolicyConditions of UseContact Us