0

I have a CGI script that uses an old database driver that is no longer supported. Instead of struggling with this old cgi script, I thought it would be easier to rewrite it in php. It works now as a php script, but I need it to be served from the same web address. When a user accesses http://somesite.com/myscript.cgi, I want it to run the php script. I tried just renaming the php script with .cgi, but that didn't work. This is on an Apache server hosted by Dreamhost. Any advice?

  • Bridger Maxwell
3
  • can you just redirect the cgi script to the php script? Commented May 3, 2010 at 6:01
  • I am not sure how to set up a redirect... Could you point me in the right direction? Commented May 3, 2010 at 6:04
  • Redirect wouldn't be of any use if the CGI was intended to be used as a POST handler. The redirect would be done as a GET and break things. Commented May 3, 2010 at 22:16

1 Answer 1

2

create .htaccess file with content

RewriteEngine On
RewriteRule ^myscript.cgi  /myscript.php

Read more about Mod_rewrite and examples

Sign up to request clarification or add additional context in comments.

2 Comments

I'd also add [QSA,L] to the end of the rule.
Another option would to be do a <Location /path/to/script.cgi> AddType application/x-httpd-php .cgi </Location>. I don't know if this would work in a directory marked as a ScriptAlias though

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.