Error 404 on things after "/" |
Hi!
I had no idea, how to describe my problem in one line ;-) Basically, if I use an URL, i got a 404. Some examples: First, https://domain works. It calls the basic controller and method. Fine. But then it begins: All called files like /dasboard.css ends up in a 404 error. If i try to call a controller eg https://domain/controller, it also ends in 404. Sorry for that explanation, I hope you understand my problem :-) Thank you
Okay, I'm a little bit further.
My controllers are loading correctly now. I did it with this .htaccess (latest working version, but it works with less code too): Code: DirectoryIndex index.php But all other stuff, like images or CSS-File are loaded as controller too... Er error message is now "404 - File Not Found - Controller or its method is not found: \App\Controllers\Dashboard::template". "Dashboard" and "Template" are directorys where the CSS-file (in this case) is located.
08-08-2021, 08:22 AM
(This post was last modified: 08-09-2021, 12:57 AM by InsiteFX. Edit Reason: Fixed spelling )
i can't see why you would want to use a .css file in a url css is about how content is displayed and you quote a css file in the head of a php /html file.
But i'm guessing not using routing . Let me give you an example : Code: $routes->get('pineapple','Login::login'); So if i put this url in browser address bar: Code: https://mydomain.com/pineapple because that route is defined it invokes class "Login" and method "login" of the class. In the class method is defined amongst other things what views to display So the approach is to set up specific routes and then what i do is lastly have a route defined as a catch all; it looks for presence of the name of a file in views. if it finds it , it displays it. if it doesn't it displays a view saying page not found. A 404 basically is saying whats being asked for ca not be found
Also make sure that your base_url in app/Config/App.php is set with an ending slash on the url /
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Thanks so far!
What I mean is, that no CSS-File, even all other files, are not loading. Sorry for my english :-) baseURL has a trailing slash. I try this three ways to check what is going on: Code: <link rel="stylesheet" href="<?= base_url('dashboard/template/xyz.css');?>"> The answer looks as every file, even in public folder, are loaded like a controller, Because "Dashboard" and "Template" in "Message" (line 4) are the first in directories in /public like in my HTML-markup above. PHP Code: {
Is there a local version of the site? If so, do you have these types of problems?
first public is your webroot
if want include statics <link rel="stylesheet" href="<?=base_url('dashboard/template/xyz.css');?>"> your css file path must be this : public/dashboard/template/xyz.css now <link rel="stylesheet" href="<?=base_url('dashboard/template/xyz.css');?>"> it work
Despite all the information given by you suggests using xampp, as in the opening of the problem you informed: ""First, https://domain works. It calls the basic controller and method.", this led me to ask if there was a local site.
Assuming then that you are using xampp, allow me to suggest the following steps for solving the problem. 1 - in xampp/htdocs, create a folder, with the name you want, where all CI4 files will be moved; 2 - in xampp/apache/conf/extra, edit the httpd-vhosts.conf file which should look similar to the one below: PHP Code: # Virtual Hosts you can remove # to enable the lines and make the necessary changes, but again let me suggest an example: <VirtualHost *:80> DocumentRoot "C:/xampp/htdocs/ci-folder/public" ServerName localhost ErrorLog "logs/ci-folder-error.log" </VirtualHost> where: ci-folder is the name of the folder created in htdocs and where the files were moved to; localhost must be informed in ServerName, because it works as an https certificate, browsers will recognize it as a "safe site", the alert "not secure" will not be displayed in the navigation bar; finally, stop/start the apache server, most likely this will solve the problems.
Thank you guys, it's solved.
Quote:your css file path must be this : public/dashboard/template/xyz.cssThat's it. But it seems, that you can use it without /public, if your .htaccess-file is configured to manage this. Maybe, my one was it, before I changed things here. This is just a private project and coding is not my job acctually, so I havn't a copy of the file, where it works without /public. Hmm. Thank you for your help and best regards |
Welcome Guest, Not a member yet? Register Sign In |