CodeIgniter:获取JS文件时出现404错误 [英] CodeIgniter: 404 error on getting JS file

查看:65
本文介绍了CodeIgniter:获取JS文件时出现404错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在安装基于CodeIgniter的项目.在登录页面中,当我尝试登录时,它一直将我重定向到登录页面,而不显示任何消息.查看http访问日志,我可以看到该网站找不到js文件:

I am installing a project that is based on CodeIgniter. In the login page when I try to login it keeps redirecting me to login page without showing any messages. Looking at http access logs, I can see that the website can not find the js files:

127.0.0.1 - - [07/Apr/2020:14:05:15 -0400] "GET /media/js/jquery-2.1.1.min.js HTTP/1.1" 404 487 "http://localhost/web/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0"
127.0.0.1 - - [07/Apr/2020:14:05:15 -0400] "GET /media/login_script.js HTTP/1.1" 404 487 "http://localhost/web/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0"
127.0.0.1 - - [07/Apr/2020:14:05:15 -0400] "GET /media/js/jquery-2.1.1.min.js HTTP/1.1" 404 487 "http://localhost/web/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0"
127.0.0.1 - - [07/Apr/2020:14:05:15 -0400] "GET /media/login_script.js HTTP/1.1" 404 487 "http://localhost/web/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0"

我搜索了此错误,有人建议更改.htaccess文件.我将其更改为以下内容,但仍然存在相同的问题.

I searched about this error and some people suggested to change the .htaccess file. I changed it to the following but still have the same issue.

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]

</IfModule>

任何人都可以帮助我解决什么问题吗?该项目位于/var/www/html/web 中,我正在使用 http://localhost/web/

Can anyone help me what is the problem? The project is located in /var/www/html/web and I am accessing it using http://localhost/web/

推荐答案

打开 application/config/config.php 文件并正确设置基本URL.

Open the application/config/config.php file and set your base URL properly.

$config['base_url'] = 'http://localhost/web';

这篇关于CodeIgniter:获取JS文件时出现404错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆