Apothem 02-13-2011, 11:40 AM How do I make it so that if I go to mysite.com, then it will run the file in cgi-bin/myprog.py?
To add to it, how do I make it so that any file with the extension "py" are not directly viewable, but can be viewed if they go to mysite.com/file_without_extension?
oesxyl 02-13-2011, 12:09 PM How do I make it so that if I go to mysite.com, then it will run the file in cgi-bin/myprog.py?
To add to it, how do I make it so that any file with the extension "py" are not directly viewable, but can be viewed if they go to mysite.com/file_without_extension?
assuming that your server is apache:
general information about how to use cgi:
http://httpd.apache.org/docs/2.2/howto/cgi.html
more specific, how to wotk with files extensions:
http://httpd.apache.org/docs/2.2/mod/mod_mime.html#addhandler
try this steps and post problems:
1. check to have as first line starting with first column of myprog.py this line:
#!/usr/bin/env python
2. move myprog.py in cgi-bin of the site
3. in cgi-bin directory run from terminal this command:
chmod 755 myprog.py
4. point your browser to this address: http://localhost/cgi-bin/myprog.py
or http://yourserveraddress/cgi-bin/myprog.py
best regards
Apothem 02-14-2011, 05:07 AM Is it possible to hide the "cgi-bin" part of the URL?
oesxyl 02-14-2011, 11:27 AM Is it possible to hide the "cgi-bin" part of the URL?
yes, is usual, one way is to use a rewrite rules
http://httpd.apache.org/docs/2.2/rewrite/
best regards
Apothem 02-14-2011, 09:12 PM Well, I know a little bit about the rewrite rules, but I do not know of any way to make it so that if the user goes to "<any_file_or_folder>" they will be directed to "cgi-bin/<any_file_or_folder>"...
Also, what is the benefit from having it in the cgi-bin versus outside of it? I have read that it is secure, but how?
oesxyl 02-14-2011, 10:59 PM Well, I know a little bit about the rewrite rules, but I do not know of any way to make it so that if the user goes to "<any_file_or_folder>" they will be directed to "cgi-bin/<any_file_or_folder>"...
Also, what is the benefit from having it in the cgi-bin versus outside of it? I have read that it is secure, but how?
:eek:, you didn't read none of the pages from the links i give it to you, isn't it?
best regards
Apothem 02-14-2011, 11:26 PM I skimmed it... :P
I mean from what I can understand:
RewriteRule ^/?(.+?) /cgi-bin/$1 [L]
That -should- do what I want... but does that mean it should be in the first line? Last line? As before I thought this would cause an endless loop.
oesxyl 02-14-2011, 11:39 PM I skimmed it... :P
I mean from what I can understand:
RewriteRule ^/?(.+?) /cgi-bin/$1 [L]
That -should- do what I want... but does that mean it should be in the first line? Last line? As before I thought this would cause an endless loop.
rewriting depend on the server settings but usualy this will work:
RewriteRule ^(.+)$ /cgi-bin/myprog.py
now if you have a requests like http://yourserver/apage the cgi script will process the request and in browser address bar you will see http://yourserver/apage and not http://yourserver/cgi-bin/myprog.py.
but, imo, this is only cosmetics and doesn't matter too much.
best regards
Apothem 02-15-2011, 03:12 AM Well, I read from one of the URLs you gave me related to Python that having the files in the cgi-bin is more secure, though I do not know why. If it wasn't a problem, I would have probably just left the files in the root directory (public_html).
oesxyl 02-15-2011, 04:05 AM Well, I read from one of the URLs you gave me related to Python that having the files in the cgi-bin is more secure, though I do not know why. If it wasn't a problem, I would have probably just left the files in the root directory (public_html).
you can't run cgi script outside of the cgi-bin directory without changing server setting. The document root of the server, public_html, is for everything you want except scripts.
http://www.w3.org/Security/Faq/wwwsf4.html
best regards
|
|