Cannot see errors in Codeigniter project

Website URL

http://ieee-restapi.great-site.net

Error Message

Other Information

I am trying to create a basic codeigniter API, as of now it has nothing fancy, the home page is codeigniter home page that it gives by default when you create a new one, which should be visible to once you hit the link but it gives 500 internal server error instead. I have tried 2 ways, putting all the folders in htdocs and even the items in public folder outside in the htdocs. Next I even tried putting the project as it is in a single folder under htdocs.
I have errors enabled and even after doing alter php config, .htaccess and inside production and development.php in the project…
I feel like giving up on hosting this and just use laravel or something, any help is appreciated.

Hi and welcome to the forum! This error is generated by the server itself, not your browser, so you need to check your .htaccess file for any errors and, if any, correct them.

4 Likes

this is my .htaccess file

RewriteEngine On
RewriteCond %{REQUEST_METHOD} GET
RewriteRule (.*) routes/get.php [QSA,L]
RewriteCond %{REQUEST_METHOD} POST
RewriteRule (.*) routes/post.php [QSA,L]
RewriteRule (.*) /public/$1 [QSA,L]
php_value display_errors 1

do you think I am missing something?
also is putting the entire project folder inside htdocs the correct way?

Being redirected to our 500 error page usually means that the .htaccess file contains invalid rules. Looking at the code you shared, I don’t see anything obviously wrong in it. But you may want to try commenting out some of the rules and see if that helps.

Yes, that’s the correct way.

I took a look at your site and I see that you didn’t do this. All your files are in a subdirectory within the htdocs folder, and that’s not going to work.

The result is that your .htaccess rules try to rewrite URLs to files/directories that do not exist. The first two RewriteRules rewrite to a folder routes, but I don’t see any folder like that at all. The last one rewrites to a folder public, but that folder doesn’t exist in current directory, only in the subdirectory.

So please move your website files from the subdirectory into the main directory. As for the .htaccess file in the main directory, I would suggest removing the current files and just using this example instead:

6 Likes

hey thanks for replying, I made the changed you suggested, and in the example .htaccess as you said.
I have done that before too, and it still gives a http 500 error.

I see the HTTP ERROR 500 too, but just on the page itself, not with a redirect. This gives me the idea that the .htaccess rules are now working, and this is a PHP code crash.

Usually, the place to start with these issues is to enable error messages so you can see why the PHP code crashed:

I did go ahead and test this for you. It seems that there is some configuration in your site that uses file paths that uses backslashes instead of forward slashes. If you developed the site on Windows, that would be the way to do it. But our servers run Linux, which uses forward slashes for directories, not backslashes, so the paths do note work. Please update your site’s configuration to use forward slashes, not backslashes, in file paths.

6 Likes

thank you the website works now, but I can’t hit the API from postman, it says you need to enable js in your browser. Does this mean I can’t use this to create an API? any solution to this?

1 Like

Correct. We provide website hosting, not API hosting.

5 Likes

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