提问人:okey_on 提问时间:8/5/2014 最后编辑:okey_on 更新时间:8/5/2014 访问量:423
Javascript/jquery 在 mod_rewrite 开启时无法加载
Javascript/jquery does not load with mod_rewrite on
问:
我仍在为.所以我的测试页面请求在我打开之前运行良好。mod_rewrite
mod_rewrite
这是 .htaccess 指令
RewriteRule ^.*$ scripts/index.php
目标PHP文件包含以下内容:
<head>
<script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js" ></script>
<script type="text/javascript" src="/libraries/colorbox-master/jquery.colorbox-min.js" ></script>
<script type="text/javascript" src="/js/index.js" ></script>
<title>index.php</title>
</head>
只需测试索引.js文件:
console.log('Hello world');
我在打开mod_rewrite的情况下收到此浏览器控制台错误消息:
Resource interpreted as Script but transferred with MIME type text/html: "http://web3.loc/js/index.js". index.php:7
Uncaught SyntaxError: Unexpected token < index.js:2
答:
1赞
wedi
8/5/2014
#1
如果您在规则之前使用
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
如果请求现有文件或目录,则不会对其进行评估,并且将提供请求的资源而不是索引 .php。
评论
index.js