.htaccess doesn't work

Jk

In Runtime
Messages
236
Well, I got bored and decied to try and make a 404 page on my server. Google made it seem really easy. I just have to edit my .htaccess and tell it to open a certain html file when it encounters a 404. I didn't have a .htaccess in my root folder so I made a blank file and named it .htaccesss. I pasted this in the file.

ErrorDocument 404 /404page.html

I saved it and then made a html file with some text in it and saved it as 404page.html. I opened a ssh and ran "sudo chmod 644 .htaccess" to make sure permssions were correct. I also restarted apache for good measure.

I go to a page that doesn't exist and I get the regular 404 error. Does anyone know why this didn't work for me? This is not the first time I had problems with .htaccess. I tried to password protect a folder before using .htaccess and I couldn't do it. I just assumed that it was something I did wrong and forgot about it. I'm guessing apache isn't looking for .htaccess or something, is there something I have to enable in apache2.conf or httpd.conf?

I am running apache 2.2.8 on xubuntu.
 
I believe (though I may be wrong).

the .htaccess files are no longer used when just left in folders, some people may choose to switch this option on, but for speed and efficiency generic tasks like this are controlled in the httpd.conf and related files.

if it's your own server then there is a chance that you can switch on the option to use htaccess files, if it's a shared server either bought or free from a hosting company you may not have this option.
 
I checked out my httpd.conf and my apache2.conf. Httpd.conf was there but it was empty. Apache2 has some settings but I didn't see any that were related to what I am trying to do. Are there any other conf files I should check?

In the apache2.conf file I found this,

Code:
#
# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives.  See also the AllowOverride
# directive.
#

AccessFileName .htaccess

It was uncommented already so I left it alone. It says that I should see something called "Allowoverride Directive" but I don't know what that is.

Also, yes this is my home server.
 
Without wanting to sound like I'm giving up, I don't have a box that has Apache on it to test this at the moment, so the manual may be more help than I am!

but I believe that the allow override would be a selection that would allow specific clients to ignore the instructions in the .htaccess file.

so you could deny access to a folder to all clients, and allow override to yourself so that you can still see this.

or you may use .htacess to password protect a part of your site to allow members only access, but at the same time allow override to the google search bot so that your articles are still referenced to drive traffic towards the premium part of your site.
(e.g someone searches, finds a likely answer on your site and then may actually pay to access the part of your site where they know that the answer is).

you may need to look to be sure that your machine you're testing from isn't allowed to override.

again, reading the manual may also help.
you may find that you have conflicting statements in your .conf file.

so you may be setting directory permissions with .htaccess, but later saying to ignore .htaccess and allow all deny none
 
Ok, thanks for the replies. I'll check out the manual (totally slipped my mind), I'm sure I will learn a lot about setting up apache so that's good.

If anyone else has an idea let me know.
 
Thanks! Works great. I'm still going to read that manual though ;)
 
Back
Top Bottom