Home > Fluid Dynamics Search Engine > Help > 1112

Initial visit to script works okay, but subsequent requests always fail

Some customers are able to view the first FDSE page successfully - either the search form or the admin login page - but after submitting the form on those pages, they receive some kind of error, often "404 Not Found" or "500 Internal Server Error".

If this happens to you, return to the main initial page and take note of the URL that appears in your browser's Address or Location bar. It should be something like this: "http://www.xav.com/search.pl":

Picture of initial visit in browser window

After submitting the form and seeing the subsequent error, check the Address or Location bar again. Does it point to the same file? (There may be different data after the question mark ? but only the part before the ? is relevant). If the Address has changed then you are facing a general class of problems whereby the script cannot detect its own path from the SCRIPT_NAME environment variable. (If, on the other hand, the Address path remains constant, then you are facing some other problem and should submit a separate bug report.) Example of problem:

Picture of second visit in browser window

This problem occurs on approximately 0.1% of web hosting providers. It happens because their web server software is not configured to return environment variables in the standard way, and yet FDSE depends the SCRIPT_NAME variable to create its self-referencing forms. To work around this problem, open the "search.pl" or "search.cgi" script and find the lines like this:

%const = (
	'pdf utility folder' => "",
	'global_lockfile_count' => 1,
	'help_file' => 'http://www.xav.com/scripts/search/help/',
	'script_start_time' => time(),
	'remote_addr' => &query_env('REMOTE_ADDR'),
	'script_name' => &query_env('SCRIPT_NAME'),
	'admin_url' => &query_env('SCRIPT_NAME') . '?Mode=Admin',
	'search_url' => &query_env('SCRIPT_NAME'),

The solution is to hardcode the path to your script instead of querying the SCRIPT_NAME environment variable. Use the code below as a template, replacing "search.pl" with whatever the script is called on your system:

%const = (
	'pdf utility folder' => "",
	'global_lockfile_count' => 1,
	'help_file' => 'http://www.xav.com/scripts/search/help/',
	'script_start_time' => time(),
	'remote_addr' => &query_env('REMOTE_ADDR'),
	'script_name' => 'search.pl',
	'admin_url' => 'search.pl' . '?Mode=Admin',
	'search_url' => 'search.pl',

After making these changes, you will have to re-upload the search script. Next, close all instances of your browser, clear the browser cache, and then revisit the main search page. Submitting forms should now work properly.

With these changes, you will have to re-customize the code if you ever upgrade or re-install the script, or if you move it to a different folder on your site.

See also the CGI specification and what is has to say about SCRIPT_NAME. Refer to this standards document when complaining to your web hosting provider about their non-standard environment.


    "Initial visit to script works okay, but subsequent requests always fail"
    http://www.xav.com/scripts/search/help/1112.html