【发布时间】:2021-03-18 06:51:48
【问题描述】:
我使用无脂肪框架编写代码并尝试使用这种结构
app/
vendor/
public/
index.php
composer.json
{
"require": {
"bcosca/fatfree": "^3.7"
},
"autoload": {
"psr-4": { "App\\": "app/" }
}
}
使用本地服务器 php -S 127.0.0.1:8000 -t public/ 我的网站显示正确,但部署在远程服务器上,带有 subdomain.domain.com 我有经典错误 p>
HTTP 404 (GET /test)
[hb/vendor/bcosca/fatfree/lib/base.php:1716] Base->error()
[hb/public/index.php:34] Base->run()
如果我尝试在我的命名空间 App 中调用一个类,我会遇到错误
内部服务器错误
Class 'App\Test' not found [/home/clients/zzz/web/test/public/index.php:26]
[/home/clients/zzz/web/test/vendor/bcosca/fatfree/lib/base.php:1955] {closure}()
[/home/clients/zzz/web/test/vendor/bcosca/fatfree/lib/base.php:1754] Base->call()
[index.php:35] Base->run()
我在带有 index.php 的 public 文件夹中的 .htaccess 是:
RewriteEngine On
RewriteBase /
RewriteRule ^(app|tmp)\/|\.ini$ - [R=404]
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /index.php [L,QSA]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
谢谢大家
【问题讨论】:
-
请分享更多细节。您还没有为
App\Test提供任何代码,因此在我看来很明显会显示此错误消息 -
谢谢你用“composer dump-autoload -o” 我想问题是文件夹名称中的大写或小写:app/app/Test.php app/Controller/Test2.php
-
请通过编辑为您的问题添加所有说明
-
如果您使用 httpd 作为您的网络服务器,
AllowOverride All是否打开?否则它甚至不会查看您的 htaccess 文件。 -
在您的 layout.htm 或容器 html 页面中,您应该有一个标签用于声明您的基本 url
<base href="https://www.example.com/">。这应该有助于为您的链接、图像、样式表等设置基本 url。
标签: .htaccess composer-php fat-free-framework psr-4