Forum Moderators: mack

Message Too Old, No Replies

What exactly is .htaccess?

         

PeterHo

10:17 am on May 1, 2003 (gmt 0)

10+ Year Member



I've heard of the file .htaccess many times but I don't see what the purpose with the file is?

grahamstewart

11:00 am on May 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It is for setting configuration options for the Apache web server.
Its useful when you are on a shared server where you can't change the httpd.conf file.

mat

11:13 am on May 1, 2003 (gmt 0)

10+ Year Member



As far as 'purpose' - how long have you got?

It has many, many uses. Just a few:

Password protecting directories
Setting default home/index pages
Blocking traffic from 'undesirables/unwanteds'
All sorts of redirection stuff, notably in conjunction with mod_rewrite

PeterHo

11:33 am on May 1, 2003 (gmt 0)

10+ Year Member



I want to make .html available for SSI. If I have a page named home.shtml I want the SSI to work if I name home.shtml to home.html. See?

Birdman

12:15 pm on May 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



From Apache Tutorial: Introduction to Server Side Includes [httpd.apache.org]

Not just any file is parsed for SSI directives. You have to tell Apache which files should be parsed. There are two ways to do this. You can tell Apache to parse any file with a particular file extension, such as .shtml, with the following directives:

AddType text/html .shtml
AddHandler server-parsed .shtml

One disadvantage to this approach is that if you wanted to add SSI directives to an existing page, you would have to change the name of that page, and all links to that page, in order to give it a .shtml extension, so that those directives would be executed.

The other method is to use the XBitHack directive:

XBitHack on

XBitHack tells Apache to parse files for SSI directives if they have the execute bit set. So, to add SSI directives to an existing page, rather than having to change the file name, you would just need to make the file executable using chmod.

chmod +x pagename.html

PeterHo

3:17 pm on May 1, 2003 (gmt 0)

10+ Year Member



are there any weaknesses with .shtml that .html doesn't?

JamesR

6:25 pm on May 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Typically .shtml pages are parsed by the server before viewing. That creates a bit of extra demand on the server than regular .html. From there on, I don't know of any more differences. Both will rank fine in search engines.

MrDolphin

2:21 am on May 15, 2003 (gmt 0)

10+ Year Member



Personally I'd use the XBitHack on trick. (I do)
The K.I.S.S principle.
Just put the XBitHack on into your .htaccess and
chmod the files you need to have SSI enabled for.
Just dont forget to chmod the file again if you ever delete
and re-upload it.

The Water Mammal