Change format from index.html to index.php but got HTTP 500 error

Website URL

I am hosting my website in Infinity. Until now, my website still works fine. From the beginning, I upload HTML5/CSS/Javascript for dry-run my front-end website and I used index.html format.
After some time coding the back-end, I decided to transform my index to index.php (Obviously also change all the data into PHP format) but when I reopen my website I got 500 error.
Does anyone have any idea about this?

Error Message I got

My directiory listing

Open your index.php with MonstaFTP (file manager)
and copy the source and paste here

then mark here all code with code formatting </> icon

You probably have a syntax error somewhere
and I’m a little suspicious of the file size of only 256B, unless there is really very little content inside on purpose.

7 Likes

As you guessed, my index.php is small as you can see because I applied the format designed by Tom Butler which I learnt in “PHP & MySQL: Novice to Ninja, 7th Edition” book.

Below is the content of my index.php

<?php
include __DIR__ . '/../includes/autoload.php';

$uri = strtok(ltrim($_SERVER['REQUEST_URI'], '/'), '?');

$MainWebsite = new \Mombaybi\MainWebsite;
$entryPoint = new \WebsiteFormat\EntryPoint($MainWebsite);
$entryPoint->run($uri, $_SERVER['REQUEST_METHOD']);

image

and that path for includes is also silly



Can you tell us briefly what you actually want to achieve?
What is the purpose of all this?

I have a feeling that maybe you could solve it with .htaccess

6 Likes

thanks Oxy for your support. I appreciate your communication.
Below is my answer to your comments.

Can you tell us briefly what you actually want to achieve?
What is the purpose of all this?

Before I was testing my front-end so I used index.html
But now I made final version of my website which includes connection to the database using MySQL so I used the format of the above-mentioned book and here comes the present

I have a feeling that maybe you could solve it with .htaccess

I will also post my .htaccess content here

##################################################


DirectoryIndex index.php index.html index.htm index2.html

ErrorDocument 403 https://errors.infinityfree.net/errors/403/
ErrorDocument 404 https://errors.infinityfree.net/errors/404/
ErrorDocument 500 https://errors.infinityfree.net/errors/500/

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:CF-Visitor} !{"scheme":"https"}
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
1 Like

@Oxy I just changed configuration as you suggest to show the error of PHP. I reload the page and got this error

Warning: include(): open_basedir restriction in effect. File(/home/vol10_7/infinityfree.com/if0_34423810/htdocs/../includes/autoload.php) is not within the allowed path(s): (/php_sessions:/tmp:/var/www/errors:/usr/share/pear:/home/vol10_7/infinityfree.com/if0_34423810/htdocs) in /home/vol10_7/infinityfree.com/if0_34423810/htdocs/index.php on line 2

Warning: include(/home/vol10_7/infinityfree.com/if0_34423810/htdocs/../includes/autoload.php): failed to open stream: Operation not permitted in /home/vol10_7/infinityfree.com/if0_34423810/htdocs/index.php on line 2

Warning: include(): open_basedir restriction in effect. File(/home/vol10_7/infinityfree.com/if0_34423810/htdocs/../includes/autoload.php) is not within the allowed path(s): (/php_sessions:/tmp:/var/www/errors:/usr/share/pear:/home/vol10_7/infinityfree.com/if0_34423810/htdocs) in /home/vol10_7/infinityfree.com/if0_34423810/htdocs/index.php on line 2

Warning: include(/home/vol10_7/infinityfree.com/if0_34423810/htdocs/../includes/autoload.php): failed to open stream: Operation not permitted in /home/vol10_7/infinityfree.com/if0_34423810/htdocs/index.php on line 2

Warning: include(): Failed opening '/home/vol10_7/infinityfree.com/if0_34423810/htdocs/../includes/autoload.php' for inclusion (include_path='.:/usr/share/pear/') in /home/vol10_7/infinityfree.com/if0_34423810/htdocs/index.php on line 2

Fatal error: Uncaught Error: Class 'Mombaybi\MainWebsite' not found in /home/vol10_7/infinityfree.com/if0_34423810/htdocs/index.php:6 Stack trace: #0 {main} thrown in /home/vol10_7/infinityfree.com/if0_34423810/htdocs/index.php on line 6
1 Like

includes is reserved by the server, which means you need to use a different folder name than that.

4 Likes

@Ziverre I will try

1 Like

try to put it like this

include __DIR__ . '/includes/autoload.php';

because in your code ../ comes out (up) of the htdocs folder and then the open_basedir restriction appears because all requested files (path) must be in the htdocs folder

9 Likes

@Oxy

include DIR . ‘/includes/autoload.php’;

thanks bro, this works

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.