如何使用 chrome 在我的本地 Apache Web 服务器中呈现 CSS 内容?
How to allow CSS content to be rendered in my local Apache web server with chrome?
我通过 head partial head.php:
7 <link rel="stylesheet" type="text/css" href="/public/css/style.css">
但是我收到警告 "Resource interpreted as Stylesheet but transferred with MIME type text/html"
我使用这个论坛作为指导:https://serverfault.com/questions/405229/apache-delivering-css-and-js-files-but-browsers-dont-render-them
我采取的行动是基于现有的论坛 post,不幸的是,上面的论坛没有被证明是成功的。在这些变化之前,我想说一下我目前的相关环境。
我正在使用 XAMPP 启动 Apache 网络服务器。我的项目特定文件位于“/php/php-practitioner/”,我用 .htaccess 文件重写了我的基础文件,该文件通过访问我的浏览器 "localhost/about" 成功证明可以工作,它加载了我的 HTML & PHP 内容 A-好的。
按照这个答案,我将以下代码添加到我的 .htaccess 文件中:
3 AddType text/css .css
4 AddType text/javascript .js
完整的 .htaccess 文件
1 RewriteEngine On
2 RewriteBase /php/php-practitioner/
3 AddType text/css .css
4 AddType text/javascript .js
5 RewriteRule ^.*$ index.php [END]
答案还指出我需要确认 mod_mime 在我的 .httpd.conf 文件中打开。我已经通过看到 "LoadModule mime_module modules/mod_mime.so" 旁边没有 # 符号来确认这一点。
重新启动我的服务器并再次加载网页。但是警告仍然存在。
此解决方案无效,仍然出现相同的警告。
我的理解是,编辑 .htaccess 文件是项目特定的,编辑 .httpd.conf 文件会影响我使用 XAMPP 创建的每个项目。
我希望 Whosebug 社区有人指出我在实施论坛 post 解决方案时存在的缺陷,或者提出替代解决方案。感谢您的帮助:)
编辑:当我检查控制台时 Chrome 浏览器中出现警告
目录:
C:xampp\htdocs
|_dashboard
|_...
|_img
|_...
|_php
|_php-practitioner (This is my project)
|_controllers
|_about.php
|_about-culture.php
|_contact.php
|_index.php
|_core
|_...
|_public
|_css
|_style.css
|_views
|_partials
|_footer.php
|_head.php
|_nav.php
|_about.view.php
|_about-culture.view.php
|_contact.view.php
|_index.view.php
|_webalizer
|_xampp
|_...
|_.htaccess
|_applications.html
|_bitnami.css
|_favicon.ico
TLDR;我的代码位于无法找到我的样式表的子目录中
嗨 Windows 2019 年 Xampp/mampp/lampp 上的用户。我有一个对我有用的修复程序,对你也有用,它与我们的环境设置有关。这是来自 Laracasts 教程。 PHP Practitioner
这对我来说是一个转折点,我已经克服了,所以你也可以!
这与您复制 jeffs 代码的错误有关,但仍然得到 404 或
您收到错误 "Resource interpreted as Stylesheet but transferred with MIME type text/html".
首先,您的 .htaccess 文件应如下所示:
RewriteEngine On
AddType text/css .css
AddType text/javascript .js
RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC]
RewriteRule ^.*$ index.php [END]
其次,您所有的项目文件必须 1000% 转到您的 htdocs 文件夹,位于:C:\xampp\htdocs
最后,如果在此之后您还有任何错误,请发送电子邮件至 roman.ozerski@icloud.com 我会亲自帮助您
我通过 head partial head.php:
7 <link rel="stylesheet" type="text/css" href="/public/css/style.css">
但是我收到警告 "Resource interpreted as Stylesheet but transferred with MIME type text/html"
我使用这个论坛作为指导:https://serverfault.com/questions/405229/apache-delivering-css-and-js-files-but-browsers-dont-render-them
我采取的行动是基于现有的论坛 post,不幸的是,上面的论坛没有被证明是成功的。在这些变化之前,我想说一下我目前的相关环境。
我正在使用 XAMPP 启动 Apache 网络服务器。我的项目特定文件位于“/php/php-practitioner/”,我用 .htaccess 文件重写了我的基础文件,该文件通过访问我的浏览器 "localhost/about" 成功证明可以工作,它加载了我的 HTML & PHP 内容 A-好的。
按照这个答案,我将以下代码添加到我的 .htaccess 文件中:
3 AddType text/css .css
4 AddType text/javascript .js
完整的 .htaccess 文件
1 RewriteEngine On
2 RewriteBase /php/php-practitioner/
3 AddType text/css .css
4 AddType text/javascript .js
5 RewriteRule ^.*$ index.php [END]
答案还指出我需要确认 mod_mime 在我的 .httpd.conf 文件中打开。我已经通过看到 "LoadModule mime_module modules/mod_mime.so" 旁边没有 # 符号来确认这一点。
重新启动我的服务器并再次加载网页。但是警告仍然存在。
此解决方案无效,仍然出现相同的警告。
我的理解是,编辑 .htaccess 文件是项目特定的,编辑 .httpd.conf 文件会影响我使用 XAMPP 创建的每个项目。
我希望 Whosebug 社区有人指出我在实施论坛 post 解决方案时存在的缺陷,或者提出替代解决方案。感谢您的帮助:)
编辑:当我检查控制台时 Chrome 浏览器中出现警告
目录:
C:xampp\htdocs
|_dashboard
|_...
|_img
|_...
|_php
|_php-practitioner (This is my project)
|_controllers
|_about.php
|_about-culture.php
|_contact.php
|_index.php
|_core
|_...
|_public
|_css
|_style.css
|_views
|_partials
|_footer.php
|_head.php
|_nav.php
|_about.view.php
|_about-culture.view.php
|_contact.view.php
|_index.view.php
|_webalizer
|_xampp
|_...
|_.htaccess
|_applications.html
|_bitnami.css
|_favicon.ico
TLDR;我的代码位于无法找到我的样式表的子目录中
嗨 Windows 2019 年 Xampp/mampp/lampp 上的用户。我有一个对我有用的修复程序,对你也有用,它与我们的环境设置有关。这是来自 Laracasts 教程。 PHP Practitioner
这对我来说是一个转折点,我已经克服了,所以你也可以!
这与您复制 jeffs 代码的错误有关,但仍然得到 404 或 您收到错误 "Resource interpreted as Stylesheet but transferred with MIME type text/html".
首先,您的 .htaccess 文件应如下所示:
RewriteEngine On
AddType text/css .css
AddType text/javascript .js
RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC]
RewriteRule ^.*$ index.php [END]
其次,您所有的项目文件必须 1000% 转到您的 htdocs 文件夹,位于:C:\xampp\htdocs
最后,如果在此之后您还有任何错误,请发送电子邮件至 roman.ozerski@icloud.com 我会亲自帮助您