CodeIgniter:获取JS文件时出现404错误

时间:2020-04-07 18:18:29

标签: php codeigniter

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

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文件。我将其更改为以下内容,但仍然存在相同的问题。

<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/

进行访问

2 个答案:

答案 0 :(得分:0)

因为您可以直接访问文件,这意味着您的 script src 路径错误

检查您的路径,并用

进行更改
def __init__(self, path_to_images):

    self._min_canny = 100
    self._max_canny = 200

    self._blur_kernel_size = 5
    self._blur_sigma_value = 0

    self._closing_iterations = 1

    self._path_to_images = path_to_images

    os.chdir(path_to_images)

    self._count = 1

    self._current_image = cv2.imread(str(self._count) + '.jpg' , 1)

    self.initialize_window()



def initialize_window(self):      

    cv2.namedWindow('Original')

    cv2.createTrackbar('Blur Kernel Size', 'Original', self.blur_kernel_size, 10, GUI_seg.on_change)
    cv2.createTrackbar('Blur Sigma Value', 'Original', self.blur_sigma_value, 5, GUI_seg.on_change)
    cv2.createTrackbar('Min Canny', 'Original', self.min_canny, 255, GUI_seg.on_change)
    cv2.createTrackbar('Max Canny', 'Original', self.min_canny, 255, GUI_seg.on_change)
    cv2.createTrackbar('Closing Iterations', 'Original', self.closing_iterations, 20, GUI_seg.on_change)

    self.one_step()

别忘了检查config.php文件中的base_url设置

答案 1 :(得分:0)

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

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