Welcome Guest, Not a member yet? Register   Sign In
Add a .js file and routes
#11

"<?= base_URL('js/menu.js'); ?> return http://domain.com/js/menu.js"
Which is bad because it doesn't work at all, even if I create a js folder in my root and pu the menu.js inside.

The thing is precisely that CodeIgniter doesn't work at all the same way I worked for last 20 years with web pages. In the past when I was asking for /public/js/menu.js I simply got /public/js/menu.js and that's all. Now in CodeIgniter it's so crazy that 2 monthes and 400+ hours of work on the CodeIgniter framework, I have an online website working well with people coming to play on, but I still don't understand how Routes work and why I got so many bugs. And as I'm often creating new pages and fonctionnalities, that's awful. So probably I am hyper stupid. Or the CI framework is not that clever. Or both.
Reply
#12

root
-- public
---- index.php
---- assets
------ bootstrap
------ css
------ images
------ img
------ icons
------ js
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#13

Why doesn't it work like this?
For the last 10 years or more, developers have switched to a system where /www/domain/public_html/, /www/domain/public/ are open to the browser.
EVERYTHING above the public/ directory cannot be obtained from the Internet. This is security so that an attacker does not see your php files from App/, vendor/, etc...
Learn a new rule: http://domain / = /www/domain/public/ Therefore, your attempts to use the public/ folder in the URL will be erroneous. Just compose the URL as if public/ has already been added
-----
I want you to continue studying CI. Feel free to ask questions
Simple CI 4 project for beginners codeigniter-expenses ( topic )
Reply
#14

CI4 changed the way. It is not CI3.
This is not about CI4's routing. It is about web server (Apache) configuration.
Quote:Important Change with index.php

index.php is no longer in the root of the project! It has been moved inside the public folder, for better security and separation of components.

This means that you should configure your web server to "point" to your project's public folder, and not to the project root. A better practice would be to configure a virtual host to point there. A poor practice would be to point your web server to the project root and expect to enter public/..., as the rest of your logic and the framework are exposed.

https://github.com/codeigniter4/CodeIgni...h-indexphp
But if you don't have permission to change the web server configuration, adding .htaccess in the project root to remove public/ in the URL is the last resort.
Reply
#15

Thanks for your messages. I need to understand the whole system better. I will send you my whole configuration later. Thanks a lot, have a good day.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB