LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-13-2015, 04:39 AM   #1
johannes.kepler
LQ Newbie
 
Registered: Jun 2007
Posts: 8

Rep: Reputation: 0
.htaccess question


Hi,

I've wrote an .htaccess file with all - I think - possible error handlings. For instance: for the 404 error I've addded the line

ErrorDocument 404 http://mysite.com/error.html?404

It works perfectly EXCEPT if the error is in the cgi-bin directory. In this case, the webserver error page appears.

What must I do to override and catch this kind of script errors in this specific dir?

Kind regards,

Johannes Kepler
 
Old 09-14-2015, 12:58 PM   #2
ButterflyMelissa
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,688
Blog Entries: 23

Rep: Reputation: 401Reputation: 401Reputation: 401Reputation: 401Reputation: 401
.htaccess exists (AFAIK) to grab server errors, I think (again, I can be wrong here) script trouble is out of reach/scope of that thing...
You will have to process the errors properly. Error handling is an art...trust me...
Please take this answer with caution, I rarely need custom error pages as I debug the scripts pretty thouroughly before they go to production
Thor
 
Old 09-14-2015, 02:23 PM   #3
johannes.kepler
LQ Newbie
 
Registered: Jun 2007
Posts: 8

Original Poster
Rep: Reputation: 0
Hi Thor,

Believe me - I know what you're talking about...

But... the problem is this: I've rented a virtual host, but without control of the server itself. The directory cgi-bin doesn't work! Not even with a simple "Hello world" cgi/pl script (I've tryed to talk with the support, put an .htaccess within with the right commands...). I have advanced scripts in Perl and compiled c - so you see my problem.

What I've done - after being tired of discussing with the support - was to create a "wrap" cgi directory where indeed my scripts work - all of them.

Still, if someone calls the cgi-bin (instead of scgi-bin I've created) I can't seem to be able to control the error traping problem...

I've made sugestions regarding the virtual host configuration...you name it. But I got nowhere.

So the problem aren't my scripts - they run just fine.

I just want to grab all the possible errors - but they just don't work in the damn cgi-bin : 404 or 403 errors continue to occurr...

That's why I've posted the question. I want to override their disconfiguration.

Kind regards,

JKepler
 
Old 09-14-2015, 03:37 PM   #4
ButterflyMelissa
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,688
Blog Entries: 23

Rep: Reputation: 401Reputation: 401Reputation: 401Reputation: 401Reputation: 401
Quote:
I want to override their disconfiguration.
LOL, good luck with that...
Quote:
I just want to grab all the possible errors
To what end? To get informed? Because...if that's the only concern...I use PHP ane I have the thing mail the errors to me...
What do you use? PERL? Error handling in PERL is described at Perlmonks...of course, assuming you have not yet done that...
Honestly, a script error should (in my very humble opinion) not be expressed toward the client/visitor...but, that is my opinion...
I'm hosted with one.com...maybe they do have PERL/CGI support that you could use...
(NO advertising here....just an opinion, One is the only host I ever had)
Please dont shoot me if I have yet to catch momentum here
Thor
 
Old 09-15-2015, 10:02 PM   #5
robertdaleweir
Member
 
Registered: Jul 2006
Location: Canada
Distribution: Fedora
Posts: 70

Rep: Reputation: 8
Quote:
Originally Posted by johannes.kepler View Post
Hi,

I've wrote an .htaccess file with all - I think - possible error handlings. For instance: for the 404 error I've addded the line

ErrorDocument 404 http://mysite.com/error.html?404

It works perfectly EXCEPT if the error is in the cgi-bin directory. In this case, the webserver error page appears.

What must I do to override and catch this kind of script errors in this specific dir?

Kind regards,

Johannes Kepler
Hi Johannes
.htaccess is Apache's way of limiting access to various Directories and Sub-Directories. If you want to limit access to a given site you can add various code to limit to only that site (ip address or FQDN Fully Qualified Domain Name).
Code:
order allow,deny
allow from all
# Yahoo-Korea (provides free email services used by some spammers)
deny from 123.0.0.0/20
# Costa Rica (CR) exceptions:
allow from 196.40.0.0/18 196.40.64.0/19
As you can see the .htaccess can be used to limit access to whatever Sub Directory it is located in and also all Sub Directories down that part of the Directory Tree.
If you have an .htaccess file in any directory on a shared server and it limits access you can get a 404 Error.
Check to see what, if any, .htaccess file exists within your cgi-bin directory as this could be causing your error.
If you are on a shared server you may well have certain setups that are defaults. See https://en.wikipedia.org/wiki/.htaccess for more information about Apache's use of .htaccess.
 
Old 09-16-2015, 06:52 AM   #6
johannes.kepler
LQ Newbie
 
Registered: Jun 2007
Posts: 8

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by robertdaleweir View Post
As you can see the .htaccess can be used to limit access to whatever Sub Directory it is located in and also all Sub Directories down that part of the Directory Tree.
If you have an .htaccess file in any directory on a shared server and it limits access you can get a 404 Error.
Check to see what, if any, .htaccess file exists within your cgi-bin directory as this could be causing your error.
If you are on a shared server you may well have certain setups that are defaults. See https://en.wikipedia.org/wiki/.htaccess for more information about Apache's use of .htaccess.
Hi,

I've thought of that. I made an experiment: I've entered my site, and navigated - via SSH - to the cgi-bin directory and runned a simple script. It worked. I tried the same thing via web broser - it didn't (404 error...).

No .htaccess file in there (checked with ls -a).

I'm puzzled...

Kind regards,

JKepler
 
Old 09-17-2015, 02:11 AM   #7
robertdaleweir
Member
 
Registered: Jul 2006
Location: Canada
Distribution: Fedora
Posts: 70

Rep: Reputation: 8
Quote:
Originally Posted by johannes.kepler View Post
Hi,

I've thought of that. I made an experiment: I've entered my site, and navigated - via SSH - to the cgi-bin directory and runned a simple script. It worked. I tried the same thing via web broser - it didn't (404 error...).

No .htaccess file in there (checked with ls -a).

I'm puzzled...

Kind regards,

JKepler
My cgi-bin directory has permissions set to 755, what are yours set at? This allows for read and execute permissions for group and others. Are there any other sub directories where the browser works on running scripts, if so check the sub directory permissions.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
htaccess question hebeles Linux - Server 1 03-07-2011 09:22 AM
.htaccess question comptech520 Linux - Newbie 18 11-20-2009 12:52 PM
.htaccess question Seventh Linux - Security 1 07-23-2006 12:31 AM
.htaccess allow question?? eagletalontim Linux - Security 4 04-23-2006 02:07 AM
.htaccess question kidestranged Linux - Software 0 03-08-2005 12:57 PM


All times are GMT -5. The time now is 09:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration