【问题标题】:ALl request to Yii2 API on Digital Ocean is giving 404 Not Found respond对 Digital Ocean 上 Yii2 API 的所有请求都给出 404 Not Found 响应
【发布时间】:2019-09-29 16:35:54
【问题描述】:

我正在使用 ubuntu 16.04 在 Digital Ocean 上部署我的第一个 yii2 api。我对 API 发出的所有请求都收到 404 not found 响应。同样的 API 在本地运行良好,没有任何问题。

我已经设置好 LAMPP 并将我的数据库链接到我的 API, 我已经在域中安装了 SSL 证书,效果很好。 当我按如下方式托管 API 时; /var/www/html/myfolder/api/....

没有请求在这个 API 上起作用,例如

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

我在 .../api/web 中有一个 .htaccess,它具有以下规则

RewriteEngine On

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

RewriteRule . index.php

我在 ../api 文件夹中也有一个 .htaccess,其中包含以下内容

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]

我不知道我的配置中肯定错过了什么。对此的任何帮助都会很棒

【问题讨论】:

  • 您确定在您的 Apache 配置中启用了重写模块吗?
  • 请问我该怎么做???因为我不记得这样做了

标签: yii2 ubuntu-16.04 digital-ocean yii2-advanced-app


【解决方案1】:

我做了 sudo vi /etc/httpd/conf/httpd.conf

然后我添加了这条规则

<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>

重启 apache 为

sudo service apache2 reload

【讨论】:

    猜你喜欢
    • 2018-11-23
    • 2014-03-20
    • 1970-01-01
    • 2021-01-06
    • 1970-01-01
    • 2023-03-05
    • 1970-01-01
    • 2016-11-02
    • 1970-01-01
    相关资源
    最近更新 更多