1

I am deploying my first yii2 api on Digital ocean with ubuntu 16.04. I receive a 404 not found response for all request i make to the API. This same API works fine locally without any issues.

I have setup LAMPP and link up my DB to my API, I have installed an SSL Certificate to the domain and it works great. When i host the API as follows; /var/www/html/myfolder/api/....

no request works on this API eg

https://example.com/myfolder/api/web/v1/beforeauths/trending

I have a .htaccess inside .../api/web with the following rules

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php

I also have an .htaccess inside ../api folder with the following containg

Options -Indexes
<IfModule mod_rewrite.c> 
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ web/$1 [L]
</IfModule>
# Deny accessing below extensions
<Files ~ "(.json|.lock|.git)">
Order allow,deny
Deny from all
</Files>
# Deny accessing dot files
RewriteRule (^\.|/\.) - [F]

I do not know what I have miss out surely in my configurations. Any help on this will be great

Nges Brian
  • 479
  • 1
  • 8
  • 22

1 Answers1

0

I did sudo vi /etc/httpd/conf/httpd.conf

then I added the this rule

<Directory /var/www/html>
. . .
 # 
 # AllowOverride controls what directives may be placed in .htaccess files.
 # It can be "All", "None", or any combination of the keywords:
 # Options FileInfo AuthConfig Limit
 #
 AllowOverride All
. . .
</Directory>

Restarted apache as

sudo service apache2 reload
Nges Brian
  • 479
  • 1
  • 8
  • 22