我在后端/ web / js / my.js中有js文件
var conf = function() {
return ('../conf.json');
}
但是无法读取conf.json文件。我收到403错误。问题是什么 ?
非常感谢
答案 0 :(得分:0)
你应该使用
var conf = function() {
return ('../js/conf.json');
}
或使用urlHelper构建正确的网址
<?= 'var url_base = "' . \yii\helpers\Url::base() .'";'; ?>
var conf = function() {
return ( url_base + '/js/conf.json');
}
答案 1 :(得分:0)
您需要将.htacces文件中的某些行添加到根目录中
#if files in the root
RewriteRule conf.php conf.php [L]
#or
RewriteRule conf.json conf.json [L]
#if files in the directory into the root
RewriteRule ^js/(.*)$ js/$1 [L]
#or images directory
RewriteRule ^images/(.*)$ images/$1 [L]