Web Development

What is an htaccess file? What can I do with the htaccess file?

A short primer on the basics of an htaccess file, what you can do with it, and why you need it.

2 years ago

If you've reached this page, it's a fair bet you already know something about the htaccess file. You know it's used by websites to do... something, but you're not quite sure what. Let's break it down!

First, what are the basics of an htaccess file?

  1. It doesn't have a filename, and its extension is always .htaccess.
  2. Normally, you want to put it in the root directory of your website (usually public/ or public_html/).
  3. .htaccess defines a set of rules that will apply to files in that folder and all subfolders.
  4. The 'ht' stands for hypertext. The 'access' stands for... access.
  5. Otherwise, it's just a normal plain text document.

That's pretty much all there is to it. Keep in mind though that since the .htaccess file does not have a filename, we call it a hidden file. This means that sometimes when using an FTP program or a file manager, you may need to look for and enable an option that says "show hidden files."


.htaccess goes in the root web directory (public/ in this case). Make sure that your FTP program or file manager has the option "show hidden files" enabled.

Really, all you need to know about the htaccess file is three things: it's just (1) a normal text file (2) called .htaccess (3) that goes in the main website directory. That's it.

So, what can we do with the htaccess file?

We can do lots of great stuff with the htaccess file. We can:

  • Tell web browsers to cache static assets (stylesheets, javascript files, and images) for better performance
  • Redirect visitors to a maintenance page when we take our site temporarily offline
  • Ban visitors by IP address
  • Password protect directories
  • Get rid of ugly .html and .php extensions in the url

And that's really just the tip of the iceberg! Overall, it's a really powerful file that can be used to speed up response times, improve the user experience, and contribute to world peace.

Post Comments(5)

JamesBef

<a href=https://lexapro2020.top/>lexapro2020.top</a>

2 months ago

Melvinfrink

Meds information for patients. Generic Name. <a href=https://lexapro2020.top/>lexapro generic tablets</a> Actual what you want to know about medicine. Get now. Medicine information. Brand names. <a href=https://orderprozaconline.top/>where to buy prozac 20 mg without insurance</a> Everything trends of drug. Get information here. Medication information leaflet. Drug Class. <a href=https://buyprozac247.top/>cost of prozac 20 mg prices</a> Some news about medicines. Read information here.

3 months ago

RobertTah

Medication information sheet. What side effects can this medication cause? <a href=https://lexapro2020.top/>where to buy cheap lexapro 10 mg tablets</a> Medication information for patients. What side effects? <a href="https://lexapro2020.top/">can you buy lexapro 10 mg prices</a> Best trends of pills. Read now. Drugs information sheet. Generic Name. <a href=https://orderprozaconline.top/>where can i get cheap prozac no prescription</a> <a href="https://orderprozaconline.top/">how to get prozac 20 mg without a prescription</a> Actual information about medicament. Read information now. Medicines prescribing information. Long-Term Effects. <a href=https://buyprozac247.top/>where to buy cheap prozac 20 mg price</a> <a href="https://buyprozac247.top/">price of cheap prozac rx for sale</a> Best trends of meds. Get now.

3 months ago

LesSleecy

Purchase Prevacid Online https://cheapcialisir.com/# - Cialis Viagra Tarifs <a href=https://cheapcialisir.com/#>cialis online pharmacy</a> Zithromax While Pregnant

6 months ago

Eleosar

Need Secure Ordering Clobetasol Medicine http://apcialisle.com/# - Buy Cialis Viagra Diario <a href=http://apcialisle.com/#>cialis price</a> Order Levothyroxine Canada Online

8 months ago

Leave a reply