Helpful Information
 
 
Category: Apache configuration
htaccess problem

I need to be able to redirect my errors to another page.... I went to the following page, and did just what it said, but for some reason it doesnt work.

http://www.javascriptkit.com/howto/htaccess2.shtml

This is what I have. but I get a 500 error

ErrorDocument 401 /ERROR_401.php

so I do this

ErrorDocument 401 /ERROR_401.php
ErrorDocument 500 /ERROR_500.php
(ERROR_401.php, and ERROR_500.php are actual pages by the way)

but i STILL get the 500 error, what gives?

Did you put
Options Indexes FollowSymLinks Includes at the top of your htaccess file?

A 500 error after you've added/changed an htaccess file usually means the error is in the htaccess file, do you have access to error logs that could give you some more information on what is going wrong? Do you have anything else in your htaccess file?

here's exactly what I have in my htaccess file


Options Indexes FollowSymLinks Includes

AuthUserFile /var/www/regAccess/.htpasswd
AuthGroupFile /dev/null
AuthName "Kinsmen Children's Centre"
AuthType Basic

require valid-user

ErrorDocument 500 /ERROR_500.php
ErrorDocument 401 /ERROR_401.php


as far as the error logs go... I assume I'd have access, I have root priveleges. Although, I dont know how to view them. I'm kind of a linux newbie. anyone know the commands to view the logs?

The logs are just text files located on your server. On another note I wouldn't put your htpassword file in a web accesible directory.

Definitely agreeing with Spook...your passwd file should be ABOVE your root directory (it looks like /var/www/ is your root, which is equivalent to yoursite.c.om).

As far as logfiles, your host may have them setup in a certain way, or accessible from some type of control panel... Although it looks like your log files MAY be in /var/log/ or /var/logfiles. However, that isn't a guarantee...and if there are multiple sites on that one machine, more than likely the logfiles will always be located out of individual local virtual directories.

As for your htaccess, nothing seems to be wrong with it. Provided that the path to your htpasswd is valid and does have read privileges, than both htaccess and htpasswd have been setup and uploaded as ASCII (no wierd LFs). And technically, your error document block should be just below the OPTIONS text, and before the authorization...Also, some hosts are odd, try removing the OPTIONS line completely and see what happens.

Thanks for the help Feyd... I'll try looking in /var/logs or something similar.

just so you know... /var/www/ is not my root of my website.
/var/www/html/ is the root. But I can see how someone could make that assumption

peace

assuming the host hasn't disabled htaccess :) I have that on one of my shared servers - a real pain! I can only do password protection...

Which host are you with?

Jee

Which host are you with?
my host is the company I work for. I don't imagine that htaccess is disabled. I mean, I set it up myself (that could very well be the problem right there), and it works fine withought those lines about the Error Documents.

whatever... maybe I'll just mess around with some stuff, and hopefully get something right. :p

OK, I've been busy with other things the past little while, so haven't had a chance to continue looking into this problem until now.

I just took a look at my error logs, and this is what it says:

[alert] [client 192.139.19.101] /var/www/html/temp/book/.htaccess: ErrorDocument not allowed here
any ide what this means?

In addition to that, I figured it might be useful if you all knew exactly what error message I get on the site


Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.



--------------------------------------------------------------------------------

Apache/1.3.22 Server at saturn.sask.trlabs.ca Port 80


I feel stupid still having to ask this but I am just at a loss for what to look for. If anybody knows anything about my problem... please give me a hand

Ok, ErrorDocument not allowed here usually means an override problem...

This means something in the server's configurations is overriding what you are trying to do...

You can using this in your htaccess, instead:


<Directory "/var/www/html/temp/book/">
AllowOverride All
ErrorDocument 404 /error.php?code=404
</Directory>


This basically tells the server to take it's configurations and lose them, because you are in charge (insert evil laugh). (You can change the first Directory to just be <Directory /> to globally override the settings.)

Or if you have access to access.conf on apache, you can search for AllowOverride None and change it to AllowOverride All (but note that you should only do this if NONE of your htaccess is working no matter what you do).

Remember that you are messing with server settings, you could be compromising configurations on the box, so you might want to get permission before doing this, or just ask the admin to change the access.conf to override all.

Ok, well... when I saw that I was super excited, cause I was sure it was going to work. But alas, I still get the exact same thing.

I was wondering... does AllowOverride have some different options? or is it just "All or None"? And where is the access.conf file located? I'd like to take a look at it, I assume I could just access it like a text file.

ehhh, ok...

Let's cover the basics...

Are you sure the file is named .htaccess and nothing else? That it doesn't have any weird LF or EL characters from Windows (remember, this is Apache and *nix). Was the file uploaded as ASCII, does it have atleast permissions of 644, and have you tried it with 755? Have you tried removing the Options Indexes FollowSymLinks Includes, considering that your box seems to be more tweaked than normal, you may not need that declaration. Are you sure you have the right path to your htpasswd file (and the same questions about naming, chmod, LF, ASCII, etc.)? Have you tried using your htaccess to JUST do error redirection without anything else (and vice versa with your password, since the box doesn't seem to be listening to your commands, it means certain directives could be disabled).

Do you even know if your box supports htaccess at all? It is possible that htaccess files have been disabled in entirety, not just certain directives...

ok, well first of all...

I know that htaccess definately is enabled. It appears with a login box whenever you try to access anything inside /var/www/html/temp/book. This is pretty much all I want, it's just that if the user hits cancel, or gets three trys wrong, they get an ugly 401 error which I'd like to fix up.


Are you sure the file is named .htaccess and nothing else? That it doesn't have any weird LF or EL characters from Windows (remember, this is Apache and *nix). Yes, the file is named .htaccess (when I go "ls -l" I see it there). As for the LF or EL characters, I dont know what those are... but I doubt that it has them. You see, I have access to the whole server, and have been connecting via SSH to make my changes. The .htaccess, and .htpasswd files were not uploaded at all. I created them right on the server in the directories I wanted them in. This doesn't involve windows at all. So I don't see how it could have those characters

I'm not sure about the permissions you talk about. 644? 755? what do these numbers represent? (this may be where I'm having my problems)

I've tried it both with and without Options Indexes FollowSymLinks Includes, but it doesn't seem to effect it either way.

Hopefully you can see something now, that could be causeing the problems.

I saw the other post asking about CHMOD'ing. I at least have an idea now what it is and how to use it. I typed chmod a=rx .htaccess in my temp/book directory (where I have my htaccess file). I assume you would only need read, and execute for this situation (if you even need both of them. Maybe I just need read or something).

I got no indication that the command worked, but there was also no error saying that it DIDN'T work.
I still get the same problem 500 error though. So I doubt if this is what caused the problem anyway










privacy (GDPR)