0
votes

I have a python script under /usr/lib/cgi-bin/ folder.
This script is accessible from URL: http://localhost/cgi-bin/test.py
Now I want to set a Apache env variable using SetEnv in a .htaccess file. Where must the .htaccess file be placed, so I can access the env variable in my python script?

Thanks F481

1
Have you tried placing it in the cgi-bin?Jon Lin
Yes, but without success.F481

1 Answers

0
votes

As they wrote here, htaccess works in all directories except cgi-bin. But, as you can see from here, there's a way around it.

Basically, you edit the <Directory "C:/path/to/cgi-bin"> section of your httpd.conf file - and put there whatever would have been in the .htaccess file in cgi-bin.

Remember to restart your apache after changes to httpd.conf

One more tidbit: there's probably already a <Directory "/var/www/cgi-bin"> in your httpd.conf. Edit it - having duplicate sections causes gray hairs.

The above worked for me for password protecting the cgi-bin directory, as using .htaccess in cgi-bin didn't work. Inserting it into the <Directory "C:/path/to/cgi-bin"> section of my httpd.conf file did work.

It now says:

<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all

    AuthType Basic
    AuthName "Scripts"
    AuthUserFile /var/secret/.htpasswrd

    Require valid-user
    Satisfy All
</Directory>