Slim Framework used in Web Hosting Subdomain

Hello,

I wrote a small Slim rest api. Locally works without problem. When I moved the api to my web hosting inside a sub domain, I get the following error:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

I have a web hosting in 1und1 in Germany. Inside the main root of my hosting I create a folder and put inside this folder the Slim application. This folder is mapped with a subdomain of my domain.

My .htaccess was put inside the folder of the slim application and contains the following:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]

Please I need help!

Best regards

Alfredo

If you can, find out what is in the PHP error log on the server. It should contain the error and give a hint on how to solve the problem. Perhaps the PHP version on the web hosting server is incorrect.

If you can’t get to the error log, you can try enabling the displayErrorDetails setting, so the error message is shown in the HTML output.

Hello llvdl,

thank you for your answer!

Unfortuntelyy I can’t get the logs on the server because I have a WebHosting and I have access just to my root folder.

The version of PHP on this server is the 5.5.38.

I configure Slim with displayErrorDetails setting but I get the same error. I thing that the request to this API doesn’t reach the php code and previously the server breaks the request and send this error back.

As I say, I have a domain, e.g. http://www.mydomain.de and in by my web hosting provider I have just access to a folder that is the root web folder. I create a subdomain, e.g. http://subdomain.mydomain.de, that is mapped to a sub folder on this root. On this subdomain I put all the Slim code. Locally works without problems.

I need help please.

Best regards

Alfredo

Result of the remote server using RESTClient in Firefox:

Result of the localhost:

Without being able to view the actual error message you are going to have a difficult time troubleshooting this. If you do figure it out, realize that you will have similar difficulty figuring out future errors as well if you can’t access the error details.

Does a simple index.php file with a simple echo 'hello world'; work? What about the Slim-Skeleton, can you get that to work?

Hello tflight,

thank you for your answer!

The problem is the apaache configuration. I delete the .htaccess file and it works. Of course only by writing the index.php in the url. It means I access to this rest api using:

htttp://sudomain.mydomain.de/index.php/

I will to take a look on the apache documentation to get the desired urls in the form http://subdomain.mydomain.de/.

Regards

Alfredo

Hi Tim,

Have the same issue. A simple echo won’t show. If i delete the .htaccess, the echo in the file does work.
The php version is: 5.4.16 (not sure if this is of any use).

Without the .htaccess file the domain.com/index.php -> still a blank page.

Not sure where to look or how to get the server logs.

Slim 3 requires PHP >= 5.5.0. phpinfo() will show you where your error logs are, look for the error_log directive and make sure they are turned on (check log_errors).

The environment is set to PHP 7.0.
This morning the website worked (not sure anymore what was in a .htaccess file) until I tried to implement to SSL rules.

At this point I keep getting “500 Internal Server Error” - Is this always a .htaccess problem?

With:
php <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^$ public_html/ [L] RewriteRule (.*) public_html/$1 [L] </IfModule>
I get a 500 Internal Server Error.

With
php RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^ index.php [QSA,L]
I get a blank page.

With
php <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] </IfModule>
I also got a blank page

No, a 500 is not always an .htaccess problem. You need to look at the server logs to see what the exact error says.

From the domain I got back:

Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace. 

Google did not do the trick for me.

It this point:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
</IfModule>

Is this the .htaccess. Result: Blank page.

Sounds like you have an infinite loop of redirects. I don’t know about your environment and what might be required. I do something like this to force HTTPS, but my environment is likely to be different.

RewriteCond %{ENV:HTTPS} !on [NC]
RewriteRule ^(.*)$ https://example.com/$1 [R,L]