Slim PHP 500 内部服务器错误
Slim PHP 500 Internal Server Error
我目前正在尝试使用以下目录树设置 Slim 项目:
public_html
|-- Mini
|-- public
|-- vendor
|-- index.php (Slim)
|-- .htaccess
文档根目录为public_html
,.htaccess
内容如下:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
尽管这个看似简单的结构,但在尝试访问域根目录或任何子目录时,除了 500 Internal Server Error
之外,我无法获得任何其他内容。
这一切都适用于我的本地 WAMP 设置。
如有任何帮助,我们将不胜感激!
已解决!
问题等同于权限问题,已通过以下方式解决:
chmod -R u+rwX,go+rX,go-w /path
我在 IONOS 的共享服务器上托管,所以我的可能性受到了一些限制。我尝试了以上所有方法和其他论坛,但没有成功。
唯一对我有帮助的是在 .htaccess 中将完整的 URL 添加到 index.php:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ http://my.domain.com/index.php [QSA,L]
但是,如果您在代码中使用 $basePath 来引用图像等非脚本内容,那将不再有效。在我的例子中,我为此目的定义了一个常量 SITE_URL。
我目前正在尝试使用以下目录树设置 Slim 项目:
public_html
|-- Mini
|-- public
|-- vendor
|-- index.php (Slim)
|-- .htaccess
文档根目录为public_html
,.htaccess
内容如下:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
尽管这个看似简单的结构,但在尝试访问域根目录或任何子目录时,除了 500 Internal Server Error
之外,我无法获得任何其他内容。
这一切都适用于我的本地 WAMP 设置。
如有任何帮助,我们将不胜感激!
已解决!
问题等同于权限问题,已通过以下方式解决:
chmod -R u+rwX,go+rX,go-w /path
我在 IONOS 的共享服务器上托管,所以我的可能性受到了一些限制。我尝试了以上所有方法和其他论坛,但没有成功。
唯一对我有帮助的是在 .htaccess 中将完整的 URL 添加到 index.php:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ http://my.domain.com/index.php [QSA,L]
但是,如果您在代码中使用 $basePath 来引用图像等非脚本内容,那将不再有效。在我的例子中,我为此目的定义了一个常量 SITE_URL。