problem: unable to load static path of .css, .js, image files with codeigniter4 |
Hello everybody!
I installed Codeigniter 4 on an apache2 server, centos 7 operating system. When accessing the website, I had trouble loading static files such as .css, .js, images. Please help me resolve this issue! application path structure: /var/www/top100mu.com/public_html/public/ /index.php /.htaccess /templates/ /style.css When accessing the style.css file path https://top100mu.com/templates/style.css , I receive a 404 error message: 404 Can't find a route for 'GET: templates/style.css'. Apache Configuration File: <VirtualHost *:80> ServerName top100mu.com DocumentRoot /var/www/top100mu.com/public_html/public DirectoryIndex index.php SetHandler "proxy:fcgi://127.0.0.1:9082 ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" AddHandler php82-fcgi .php Action php82-fcgi /cgi-bin/php82.fcgi <Directory "/var/www/top100mu.com/public_html/public"> AllowOverride All Require all granted </Directory> ErrorLog /var/log/httpd/top100mu.com_error.log CustomLog /var/log/httpd/top100mu.com_access.log combined </VirtualHost>
Did you enabled mod_rewrite?
See https://codeigniter4.github.io/CodeIgnit...od-rewrite
mod_rewrite has been enabled. Do I have to edit anything in the .htaccess file?
No. the default public/.htaccess should work in most cases.
But the error "Can't find a route for 'GET: templates/style.css'." is a CI4's error message. "templates/style.css" is a file, so it should be served by Apache, but Apache passed the request to CI4. So something wrong with your Apache configuration.
|
Welcome Guest, Not a member yet? Register Sign In |