Forum Moderators: phranque

Message Too Old, No Replies

What do YOU use htaccess for?

         

Livenomadic

4:44 pm on Oct 1, 2004 (gmt 0)

10+ Year Member



I just figured out (thanks for some excellent WebmasterWorld members) how to turn on Gzip and now my pages are 87% smaller!

I knew sort of what htaccess did, but I never realized how powerful it was.

So, what do you use htaccess? Anything really awesome?

pete_m

4:55 pm on Oct 1, 2004 (gmt 0)

10+ Year Member



The most common things are probably mod_rewrite to create search engine friendly URLs, and password protecting directories along with a .htpasswd file.

I also set expiration times for my image files so browsers don't try to download them everytime a page is loaded. Also, you can set php variables in .htaccess - like include paths, for instance.

Apache is so flexible - you can do all sorts of tricks with .htaccess and the config files.

Birdman

5:21 pm on Oct 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To add to that list:

  • Stop image hotlinking
  • Ban user agents(unfriendly)
  • Ban by ip address
  • Redirects(301 etc)
  • Set directory index(the file that is opened when a folder is requested)
  • Add handlers(make html parse as php, etc.)

coopster

6:40 pm on Oct 1, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Just a side note, Livenomadic, and it's something that pete_m referred to -- .htaccess files are per-directory overrides that can and should be set in the main configuration file whenever possible. On a shared server, this is obviously not quite as easily done, if at all.

More reading is available on Apache's web site:

[httpd.apache.org...]

Don't get me wrong here, I'm not telling you you shouldn't use them! I'm merely making sure that these per-directory override files are better understood :)