Hello, I'm having this error in a new hosting where I just uploaded my website. I didn't have this problem in my old hosting:


404 Not Found
Not Found
The requested URL /cgi-bin/php/myscript.php was not found on this server.


Do you know what could be causing the error? It is trying to execute the PHP script in the cgi-bin/php folder, when my php scripts are all in public_html/mysite/ (there are several in different folders).

Is it some Apache or php.ini configuration problem in the hosting?

Or I need to add some header? I tried adding #!/usr/bin/php as the first line of the php script both outside and inside of the php tags but seems it's not solving the problem.

The PHP version is 5.1.4. Could this be the problem? I was using a PHP version 5.2 in my old hosting.

Hi,

First things first:

The cgi-bin (common gate interface bin) is a storage area for CGI/Perl scripts.

I am not sure why you are placing your PHP files in their, PHP is a server-side language and it should execute anywhere on a server with PHP enabled.

In regards to your 404 error, are you sure your files are located in the following location: /cgi-bin/php/myscript.php ?

Also /cgi-bin/ is a relative folder, if you like a kind of virtual folder. I would suggest you move your files outside this folder unless you have a valid reason for having them in there... I am sure they are not secure in their as the CGI-BIN is generally chmod'ed to 0777 (read, write, execute) persmissions.

Sorry for the long reply.

Kyle

commented: Thank you! +0

Hello Kyle, thanks a lot for your reply.

I'm not placing my php scripts in the cgi-bin/php folder, my scripts are inside the folder structure of my website. As you say, they were executed fine anywhere in the server when I had my website in another hosting so I thought this would be the case in this new hosting aso, but for some reason it isn't.

Anyway, I tried copying the php scripts in the cgi-bin/php folder, but still it's not working because it is trying to find the whole path following the folder. For instance, if the script is in:

www.mywebsite.com/edition/myscript.php

it is trying to execute:

cgi-bin/php/mywebsite.com/edition/myscript.php

which of course can't find.

I'm really lost here...

who is your host, i have never seen this format of hostinf before.

I am off to bed now, its 2355 GMT here but i will reply in the morning if noone else has fixed it b4 then.

Nyt.

Kyle

Hello Kyle, thanks a lot for your reply.

I'm not placing my php scripts in the cgi-bin/php folder, my scripts are inside the folder structure of my website. As you say, they were executed fine anywhere in the server when I had my website in another hosting so I thought this would be the case in this new hosting aso, but for some reason it isn't.

Anyway, I tried copying the php scripts in the cgi-bin/php folder, but still it's not working because it is trying to find the whole path following the folder. For instance, if the script is in:

www.mywebsite.com/edition/myscript.php

it is trying to execute:

cgi-bin/php/mywebsite.com/edition/myscript.php

which of course can't find.

I'm really lost here...

Why don't you move the php folder out of the cgi-bin and place it at the proper location so the url's dont need rewriting. Also having php files in a cgi-bin can cause problems as for example the server may treat the php files as cgi/perl files. And permissions are different in the cgi-bin directory resulting in possible productivity loss. So I would suggest moving those files to a place where they wont need rewriting to.

commented: Thank you! +0

I own two hosting companies and I can tell you that this shouldn't be happening. Apparently the server is setup to expect all scripts to be in the cgi-bin folder or to search there if it doesn't find them where expected. It may not even support PHP - have you checked?

Your hosting support people should be readily available and very responsive - and these should be the people you're directing questions to.

As you said, you didn't have this problem on your old server, and if you've uploaded your files into the same folders as before, then you shouldn't be having the problem on this server either. I suspect you'll be changing hosting companies again soon.

commented: Thank you! +0

Finally the guys at the hosting server changed something and it's working now.

You are right it was something on their end. I was worried maybe I was misssing some header option, like that one I mentioned before, the #!/usr/bin/php header, which honesly I have no idea what it does really. Ah well it wasn't that anyway.

Many many thanks for your replies!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.