简体   繁体   English

CSS包含用vhost弄乱的路径

[英]CSS include path messed up with vhost

I am currently using SLIM as a PHP framework. 我目前正在使用SLIM作为PHP框架。 I have a slight problem with paths (below is my file hierarchy). 我的路径有一个小问题(下面是我的文件层次结构)。

I'd like to be able to have a clean url that presents itself like this: " https://cppoi/home ", but by doing this my html includes no longer work as they are supposed to. 我希望能够有一个干净的url,这样显示自己:“ https:// cppoi / home ”,但是通过这样做,我的html不再像预期的那样起作用。 It's as if they can't see outside their "bubble" or the vhost bubble, which points to "application/". 好像他们看不到指向“ application /”的“气泡”或虚拟气泡一样。 If I however set it to point to the entire project folder, which includes the assets folder in which my stylesheets are located, my includes work again but my url becomes " https://cppoi/application/home " which is uglier. 但是,如果我将其设置为指向整个项目文件夹,其中包括样式表所在的资产文件夹,则我的include会再次工作,但是我的URL会变成“ https:// cppoi / application / home ”,比较难看

There is probably a very easy solution to this, thanks for your time. 谢谢您的宝贵时间,对此可能有一个非常简单的解决方案。

测试

There is no super easy solution, your app setup doesn't necessarily follow best practices. 没有超级简单的解决方案,您的应用设置不一定遵循最佳实践。 You would usually setup a public folder that contains only your front controller index.php and any public assets. 通常,您将设置一个public文件夹,其中仅包含前端控制器index.php和任何公共资产。 (+ stuff like .htaccess . This public folder is then exposed via webserver, nothing else. That way your code is not accessible from the web, but your main entry point (front controller) and your assets are. (+东西一样.htaccess 。这个public文件夹,然后通过网络服务器暴露出来,仅此而已。这样,你的代码是不是通过Web访问,但你的主入口点(前端控制器)和你的资产。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM