Action in .htaccess don't work

AuthType Basic
AuthUserFile /home/kuikun/public_html/test/sub/.htpassword
Action cgi-script /test/sub/a.cgi
AuthName "Our Members Only Section"

<Limit GET POST>
Require valid-user
</Limit>

===================================

when login success, it never execuse a.cgi

how should i do ?
tong111797Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

frugalCommented:
The first argument has to be the mime type of the files that you want to have that action applied to, not the mime type of the action itself. In your case, I'm assuming that you want the script a.cgi to be run whenever pages are served up. So the action would be:

Action text/html /test/sub/a.cgi

Also, I'm a bit curious about the path that you have listed above to the cgi script given that on the line above you have a test and sub directories within your code. Is the cgi program located in this same directory or is there actually a directory /test/sub? If a.cgi is in your public_html then the path must be the complete path as you have in the line above.

Finally, you need to make sure that cgi execution is allowed for the directory where a.cgi is located. You can either add a .htaccess file to the directory where a.cgi is located and put the line:

Options +ExecCgi

However, a better solution (especially if the webserver is setup to deny .htaccess files) is to put this line in your httpd.conf as follows:

<Directory /path/to/a.cgi/>
Options +ExecCgi
</Directory>

Hope this helps!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tong111797Author Commented:
after i edited .htaccess
================

AuthType Basic
AuthUserFile /home/kuikun/public_html/test/sub/.htpassword
#AddHandler cgi-script cgi
#Action cgi-script a.cgi
AuthName "Our Members Only Section"
Action text/html /home/kuikun/public_html/test/sub/a.cgi
Options +ExecCgi

<Limit GET POST>
Require valid-user
</Limit>


my a.cgi contain with
===============

#!/usr/bin/perl

open(mmm,">>/home/kuikun/public_html/test/sub/index.html");
print mmm "$ENV{REMOTE_USER}\n";
print mmm "$ENV{REMOTE_ADDR}\n";
print mmm "$ENV{DOCUMENT_ROOT}\n";
close(mmm);


the result is

Not Found

The requested URL /home/kuikun/public_html/test/sub/a.cgi/sub/index.html was not found on this
server.
0
tong111797Author Commented:
#Options +ExecCgi
AuthType Basic
AuthUserFile /home/kuikun/public_html/test/sub/.htpassword
#AddHandler cgi-script cgi
#Action cgi-script /home/kuikun/public_html/test/sub/a.cgi
AuthName "Our Members Only Section"
Action text/html /test/sub/a.cgi?

<Limit GET POST>
Require valid-user
</Limit>

============================

this code work well.... conclusion..
it musts add "?" at the end of cgi file.
otherwise it will see as path.

and this cgi will execuse every time when visitor access
file under path /test/sub

I would like to run only one time. How should I do ?
or i must use Cookie ?


thank for advance.
tong/.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.