0

I'm trying to deploy a RESTful web application which was developed in a local machine. The same code works perfectly in the local XAMPP server but fails to load upon uploading into a remote Linux server.

Here'e the .htaccess file,

RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ %{ENV:BASE}index.php [QSA,L] 

Since it doesn't works, I've also tried with the small modification,

RewriteEngine On RewriteBase /slim/ RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php [QSA,L] 

I'm still getting error 500. Seems like the remote server is preventing the scripts or its files from getting executed. This is absolutely strange because the same codes works perfectly in local server. Any kind of help or suggestion would be realty appreciated.

The file permission for the file is also set to 777 (read, write, execute)

Current PHP version in remote server is PHP V5.6

3
  • If you get an error, please show us the log entry in the error.log. Commented Dec 17, 2015 at 11:20
  • 3
    On a 500 error, always inspect the webserver log. If you don't have access to it directly, ask your sysadmin/hosting provider to look into it for you. Commented Dec 17, 2015 at 11:20
  • Also, never use chmod 777. See How will a server become vulnerable with chmod 777? Commented Dec 17, 2015 at 11:21

2 Answers 2

2

I think you are using suphp on your server and you have setup 777 permission for your all files and that is the reason you are facing this issues. Please change you all file permission to 644 and folder permission to 755 and check your domain URL.

Sign up to request clarification or add additional context in comments.

1 Comment

Awesome, I didn't check the file permissions until I read this!!! thanks.
0

To be able to run your PHP slim app on live server e.g IONOS servers,
there are two things you need to sort out:
1. The webserver:
Create a .htaccess file in /var/www/html/myapp (root directory path) where myapp directory stores all your slim app files.

RewriteEngine On
RewriteBase /myapp
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]

The key thing here is the RewriteBase directive which must be set.
2. Your Slim 4 app config
In your index.php, add:

$app->setBasePath('/myapp'); 

Viola!

Follow link for detailed explanation https://akrabat.com/running-slim-4-in-a-subdirectory/#the-web-server-apache

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.