gpt4 book ai didi

javascript - .htaccess AddType 不起作用

转载 作者:行者123 更新时间:2023-11-28 17:48:31 25 4
gpt4 key购买 nike

我为我正在工作的站点的 urlrewrite 创建了 .htaccess 文件。添加 .htaccess 后,它停止加载 JavaScript 和 CSS。所以我随后添加了 AddType text/css .cssAddType text/javascript .js。但我得到了同样的错误。以下是我的 .htaccess 代码:

<IfModule mod_rewrite.c>

RewriteBase /downsouthlk.comV3/
RewriteEngine On

AddType text/css .css
AddType text/javascript .js

#Turn on the rewriting engine

RewriteRule ^admin/dash/?$ /admin/dash.php [NC,L]
RewriteRule ^admin/addcity/?$ /admin/addCity.php [NC,L]


</IfModule>

这是我从 chrome 开发者选项中得到的错误:

Resource interpreted as Script but transferred with MIME typetext/html

Resource interpreted as Stylesheet but transferred with MIME typetext/html

最佳答案

您的问题是在您的 css/js 链接中使用了相关链接。确保在你的 css、js、图像文件中使用绝对路径而不是相对路径。这意味着您必须确保这些文件的路径以 http:// 开头或斜线 / .

或者您可以尝试将此添加到您页面的 HTML header 中:<base href="/" />

关于javascript - .htaccess AddType 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22778481/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com