Php.cgi relative links

software development

#1

Hi.

I was wondering if anyone here know why php (or something else) would parse a relative url with the “php.cgi” extensions.

Reason is, I moved a script from a previous host to a dreamhost server, and certain links are not working.

The problem is the links (script generated) end up something like:

http://www.site.com/scriptfolder/php.cgi?dir=Statues-Estatuillas

Which generates a 404, since the script is just called index.php.

It should be:
http://www.site.com/scriptfolder/index.php?dir=Statues-Estatuillas

The part of the script that is in charge of this starts somehow like this:

echo “<a href=”?"

and concatenates the rest of variables needed…

If more info is needed please let me know. I haven’t been able to find much info about this, and I’m still not that much of a pro in php coding =)

Thanks for your reply.


#2

php.cgi is the executable running the PHP script. A lot of information is stored in the CGI environment and the name of the executable will be one of the variables. However the url path passed is a different variable, so the script would need to be modified appropiately.

:cool: [color=#6600CC]Atropos[/color] | openvein.org


#3

yes, I understand now.

Actually the culprit was a line starting like this:

echo ‘<a href="’.basename(SCRIPT_NAME).’

changed the variable to index.php, problem solved.

Although I’m not sure if this is the best way to do it, at least it works for now.

Thanks for the quick reply!