Looking for advice on best way to redirect from webroot to cgi app

I have …

I would like …

  • When someone types mydomain.net into their browser, for my myapp.cgi to be launched.

What is the best way to do this?

I will answer my own question …
With Godaddy (where this particular site is hosted), they have domain forward features associated with DNS management.

Very easy to set up.

you can put the CGI there as index.cgi and have that be used as default document.

Interesting - but please clarify - I can put index.cgi where: In the webroot or in the cgi-bin directory?

If in the cgi-bin directory, then I assume the user will need to browse to mydomain.net/cgi-bin, right?
If in the webroot, then I assume the user can just browse to mydomain.net, right?

Another option is to place index.html in the webroot with a refresh meta-tag in the block

which will redirect the browser.

I talk about what I suggested on my blog:
http://www.mbsplugins.de/archive/2014-01-20/Tip_of_the_day_avoiding_cgi_in/monkeybreadsoftware_blog_archive

[quote=72115:@Mark Pastor]I have …

Create a index.php file with the following content and replace index.html with it:

[code]<?php
$myurl=$_SERVER[‘HTTP_HOST’];

switch ($myurl)
{
case “www.mydomain.net”:
header(“Location: http://www.mydomain.net/cgi-bin/myapp.cgi”);
break;
case “mydomain.net”:
header(“Location: http://mydomain.net/cgi-bin/myapp.cgi”);
break;

default:
// echo $_SERVER[“HTTP_REFERER”];
header(“Location: http://www.mydomain.net/cgi-bin/myapp.cgi”);
}
?>[/code]

[quote=72115:@Mark Pastor]I would like …

  • When someone types mydomain.net into their browser, for my myapp.cgi to be launched.

What is the best way to do this?[/quote]

If you wish to hide the cgi from the URL, then you can add the following to the .htaccess file in the webroot (assuming you’re using Apache, which I’m sure you are):

RewriteEngine On RewriteRule ^/?$ /cgi-bin/myapp.cgi [L,QSA]

This will leave the URL at mydomain.net/ but actually run the cgi.

Awesome Jay! That works great.
All of these suggestions are very helpful. I am leveraging different approaches for different main and subdomains of this domain, and things are really coming together.

Thanks to all!