Slim路由在服务器上不起作用

问题描述 投票:0回答:2

我正在php slim框架中创建REST API,并且我使用的还不错。在本地,一切都运行良好,但是我无法在线运行它。我有一个来自大学的服务器,那里有很多学生项目,所以到我的休息API的路线是:

/ var / www / projects / myProject / bpsql

在bpsql文件夹中,带有composer.json文件的公共,供应商和应用程序文件夹。在我的公共文件中,有htaccess文件正在引起麻烦(我认为)。该文件应如何显示,您认为我应该对此进行一些更改:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]

我尝试添加行RewriteBase projects/myproject/bpsql/public,但没有任何效果。

任何帮助将不胜感激!

编辑:

apache modules on server got by `print_r(apache_get_modules());



     Array
(
    [0] => core
    [1] => mod_log_config
    [2] => mod_logio
    [3] => mod_version
    [4] => prefork
    [5] => http_core
    [6] => mod_so
    [7] => mod_alias
    [8] => mod_auth_basic
    [9] => mod_authn_file
    [10] => mod_authz_default
    [11] => mod_authz_groupfile
    [12] => mod_authz_host
    [13] => mod_authz_user
    [14] => mod_autoindex
    [15] => mod_cgi
    [16] => mod_deflate
    [17] => mod_dir
    [18] => mod_env
    [19] => mod_mime
    [20] => mod_negotiation
    [21] => mod_php5
    [22] => mod_reqtimeout
    [23] => mod_rewrite
    [24] => mod_setenvif
    [25] => mod_ssl
    [26] => mod_status
)
/var/www    //echo getenv("DOCUMENT_ROOT") ;
php .htaccess slim
2个回答
3
投票

好,解决了这个问题,所以如果将来有人遇到相同的问题,这将为我解决这个问题:

  1. 在Apache中启用重写模块(马丁的答案)
  2. 在httpd conf文件中,我将AllowOverRide None更改为AllowOverride All

特别感谢@David Pastore为解决问题提供的所有帮助和协助。


3
投票

我猜您在Linux上,但是如果是这样。似乎您没有启用mod重写。因此以下内容可能会有所帮助。

a2enmod rewrite
service apache2 restart

但是为了更容易地通过https://stackoverflow.com/help/mcve进行错误修复,有关设置和/或日志的更多信息会有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.