cancel
Showing results for 
Search instead for 
Did you mean: 

htaccess in cgi-bin

Marteknet
Grafter
Posts: 577
Registered: 13-10-2007

htaccess in cgi-bin

Has anyone used .htaccess in the cgi-bin to redirect on missing pages errors 404. i don't seem to be able to get it to work, maybe i am missing something, any advise would be very helpful.

Peter.
11 REPLIES
N/A

htaccess in cgi-bin

If you set the .htaccess directive in the folder above the cgi-bin, it will apply to the cgi-bin, and every other folder as well. I'm not sure if it will work just for the cgi-bin folder or not.
Marteknet
Grafter
Posts: 577
Registered: 13-10-2007

thanks

ta thats helpful, have you any idea how to set a re-direct for each folder in the cgi-bin as i used to have a few php scripts running from various folders in the cgi-bin and now need to do a individual re-direct for each one.
N/A

htaccess in cgi-bin

I don't follow what you mean but something like may do what you want.


RewriteEngine On
RewriteRule cgi-bin/script.php /newscript.php
Marteknet
Grafter
Posts: 577
Registered: 13-10-2007

more details

thanks for the advice.

Heres what i am trying to do.

i used to have some php script in the cgi-bin. i users called them with variables in the url.

eg.
http://cgi.user.force9.co.uk/cgi-bin/dir/script.php?data1=val1&data2=val2

Because the way the new server works php will not run from the cgi-bin.
so I have moved the php scripts to a sub-directory in the server root
and they work fine if accessed via a call the their now URL address

ie.
http://cgi.user.force9.co.uk/php-bin/dir/script.php?data1=val1&data2=val2

what i need is a way of catching any calls to the orginal scripts and point them to the same scripts but at their new locations.
N/A

htaccess in cgi-bin

Try putting

RewriteEngine On
RewriteRule cgi-bin/script.php /php-bin/script.php [QSA,L]
in your .htaccess file.
Marteknet
Grafter
Posts: 577
Registered: 13-10-2007

still not working :-(

I have tried it and it doesn't want to work I am getting this error message when the script is called

Forbidden
You don't have permission to access /cgi-bin/pstats/pstats.php on this server.
Apache/1.3.29 Server at cgi.martek.force9.co.uk Port 80

I have chmod the pstats directory and files to 755 and even tried 777 but its no good I still get the same error.

The reason this is important to me is because there were quite a few people who used the scripts to display their seti@home statistics on their own pages. And in line with my privacy statement I don't hold their email addresses and have no way of contacting them to inform them of the new URL for the scripts.
Marteknet
Grafter
Posts: 577
Registered: 13-10-2007

htaccess in cgi-bin

I have just noticed that having the RewriteRule in the .htaccess file stops all types of scripts working in the cgi-bin , .pl, .cgi and .php. That's worse then the current problem.

Thanks for your help anyway. I am going to research what happens when a php script is called but not found. perhaps I can fudge a solution to this issue by making the server run a cgi script instead of a php script, but only in one directory, a long shot I know but worth a try.
N/A

htaccess in cgi-bin

The easiest way is to put one line in the .htaccess file for each error message you want to control...

ErrorDocument 404 http://mysite.co.uk/myerrorpage.html

TaDaa!
Marteknet
Grafter
Posts: 577
Registered: 13-10-2007

many thanks

While it's not exactly what I wanted it works in a fashion, I have implemented this and the people using my scripts will now at least see my seti@home statistics instead of a server error, realise something has changed and go to my pages to generate a new line of code to use and save to view their own statistics.

Many thanks for all your help.

Regards Peter.
N/A

htaccess in cgi-bin

I'm not sure if this would be any better, but I use this 301 redirect error to move my old site to a new site:
RewriteEngine On
RewriteRule ^(.*)$ http://blog.edbateman.com/$1 [R=301,L]
And that sends anything at http://myhost/blah/blah2 to
http://blog.edbateman.com/blah/blah2

I think that this might do just what you want.
Marteknet
Grafter
Posts: 577
Registered: 13-10-2007

htaccess in cgi-bin

Thanks for the info.

I think i will stick with the missing file redirct in htaccess, I have deleted the old scripts in the the cgi-bin so any calls to the deleted files will now go to the new locations in crofters.