找不到PHP-Slim-Restful API 404页面

时间:2018-01-06 11:38:02

标签: .htaccess rest

每次我连接到api时,都会收到404错误。

我认为这是我的httpd.conf的问题。

我的api正在调用/ api / signup

我有一个.htaccess进入我的api文件夹:

RewriteEngine On

#RewriteBase /api/

Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"

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

我的httpd.conf如下:

ServerRoot "/etc/httpd"

Listen 80

Include conf.modules.d/*.conf


User apache
Group apache

ServerAdmin root@localhost

<Directory />
    AllowOverride none
    Require all denied
</Directory>

DocumentRoot "/var/www/html"

<Directory "/var/www">
    AllowOverride All

    Require all granted
</Directory>


<Directory "/var/www/html">

    Options Indexes FollowSymLinks

    AllowOverride All

    Allow from all

    Require all granted
</Directory>

<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

<Files ".ht*">
    Require all denied
</Files>

ErrorLog "logs/error_log"

LogLevel warn

<IfModule log_config_module>

    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>

      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    CustomLog "logs/access_log" combined
</IfModule>

<IfModule alias_module>

    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

</IfModule>

<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

<IfModule mime_module>

    TypesConfig /etc/mime.types

    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</IfModule>

AddDefaultCharset UTF-8

<IfModule mime_magic_module>

    MIMEMagicFile conf/magic
</IfModule>

EnableSendfile on

IncludeOptional conf.d/*.conf

当我调用其他文件时,它没有返回404,所以我猜我的httpd.conf文件有问题,但我无法发现问题。

有什么想法吗?

提前致谢

1 个答案:

答案 0 :(得分:1)

我发现了问题..

我在更改为httpd.conf之前做过:

Options Indexes FollowSymLinks

    AllowOverride All

    Allow from all

    Require all granted

之前不是全部。

问题是:我没有重启apache。重启后它可以正常工作