我遇到了在Slim Framework上为这条路线呈现视图的问题:
这是我的应用程序目录结构:
|--project
|--public
|--assets
|--css
|--main.css
|--index.php
|--.htaccess
|--app
|--asset
|--route.php
|--controllers
|--HomeController
|--AuthController
|--models
|--views
|--auth
|--signup.php
|--home
|--index.php
|--bootstrap.php
路线:
$app->get('/[{home}]', 'app\controllers\HomeController:index')->setName('home');
一切正常,包含所有资产文件(在公共文件夹的css文件夹中),css文件的uri是
http://localhost:8081/slim-auth/public/assets/css/main.css
但是路线:
$app->get('/auth/signup', 'app\controllers\AuthController:getSignUp')->setName('auth.signup');
访问css文件时出现404错误,浏览器尝试通过uri访问css文件:
http://localhost:8081/slim-auth/public/auth/assets/css/main.css
而不是:
http://localhost:8081/slim-auth/public/assets/css/main.css
虽然显示了所请求路线的内容,但未使用404响应状态
呈现css将路线更改为:
$app->get('/signup', 'app\controllers\AuthController:getSignUp')->setName('auth.signup');
一切似乎都像家庭路线的情况一样正常。
无论如何我可以绕过这个吗?如果能够尽快解决这个问题我真的很感激。