Need help finding a string within a file

s3kk3y

Well-Known Member
Oct 12, 2002
93
0
156
In my error_log, I have almost 1000 entries of this line:

[Wed Mar 26 04:16:49 2003] [notice] cannot use a full URL in a 401 ErrorDocument directive --- ignoring!

I know why I am getting that and i want to correct whoevers .htaccess file that is causing those messages.

What cmd can i use to search all .htaccess files within /home/ searching for the string "401" and "http"?
 

taivu

Well-Known Member
Nov 22, 2001
65
0
306
find . -name ".htaccess" -type f -print | xargs grep -e 'Error.*401.*http' /dev/null

should do what you want, assuming you are in /home directory. The answer to your question would be:

find . -name ".htaccess" -type f -print | xargs grep -e '.*401.*http' /dev/null
 

s3kk3y

Well-Known Member
Oct 12, 2002
93
0
156
Thanks,

It first didnt find any matches, so i made it look for just "401" and it came up with 1 user.

The weird thing is, he had his .htaccess set as:

ErrorDocument 401 /index.htm

Does it have to be the full path? I changed it anyways, but i want to make sure that i set it correctly. I changed it to:

ErrorDocument 401 /home/username/public_html/index.htm
 

Website Rob

Well-Known Member
Mar 23, 2002
1,501
1
318
Alberta, Canada
cPanel Access Level
Root Administrator
To read the error msg. another way, it would sound like, "Since a complete URL is not being used for the re-direction, the Error directive will be ignored."

Simply use a full URL and there should not be a problem.
 

taivu

Well-Known Member
Nov 22, 2001
65
0
306
Originally posted by s3kk3y
The weird thing is, he had his .htaccess set as:

ErrorDocument 401 /index.htm
That is how it should be. Have you checked your httpd.conf? Make sure you have no ErrorDocument directives with full URL in there.

grep -e 'Error.*401.*http' /usr/local/apache/conf/httpd.conf
 

s3kk3y

Well-Known Member
Oct 12, 2002
93
0
156
i double checked my httpd.conf and the only line with 401 is:

ErrorDocument 401 /401.shtml

My httpd has thousands of directive error lines now. =(
 

taivu

Well-Known Member
Nov 22, 2001
65
0
306
Well, if there's an entry in error_log, there must be a matching request entry in your access_log or (most likely) in one of the domlogs. Grab the latest error date and time and convert it to the format used in the access logs. I'll use the one from your first post in this thread in my example.

Error_log entry:
[Wed Mar 26 04:16:49 2003] [notice] cannot use a full URL in a 401 ErrorDocument directive --- ignoring!

Access log date and time would be: "26/Mar/2003:04:16:49"

find /usr/local/apache/domlogs -type f -print0 | xargs -0 fgrep -l "26/Mar/2003:04:16:49"

should give you a list of files that contain that timestamp. If no luck, run the same for /usr/local/apache/logs.