I am trying to get routing working in my SLIM PHP app. I need to create a .htaccess file in the same directory as my index.php like so :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
So I have my index.php in /var/www/html/example.co/public_html/API and also in that same folder is the .htaccess file mentioned above.
I have configured my virtual hosts in example.co.conf like so:
<VirtualHost *:80>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin webmaster@example.co
ServerName www.example.co
ServerAlias example.co
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /var/www/html/example.co/public_html
# Log file locations
LogLevel warn
ErrorLog /var/www/html/example.co/logs/error.log
CustomLog /var/www/html/example.co/logs/access.log combined
<Directory "/var/www/html/example.co/public_html">
AllowOverride All
</Directory>
</VirtualHost>
Now if I try to access any routes in my PHP app, even ones that worked before I get the error message:
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
I know this is a problem because of my .htaccess file because if I remove it the root link will work, i.e. www.example.co/API/. Any ideas what I am doing wrong with these files here? I am tearing my hair out over it. I have googled around and tried numerous combinations of different things in the .htaccess file but not had any luck. If someone could point me in the right direction I would massively appreciate it. thanks!
(Running a LAMP server on Linode)