404 page not found... - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: 404 page not found... (/showthread.php?tid=44002) |
404 page not found... - El Forum - 08-03-2011 [eluser]pickupman[/eluser] [quote author="Ivar89" date="1312391209"]Yhea I really should, but if I do that I have to edit allot, I mean every controller need to be edited to ci_controller and probably some other stuff from which I do not know, so it iwll take a while and I am SWAMPED atm But the rpoblem is my laptop because on my work laptop it works flawlesly[/quote] This is why you should extend the Controller class or use a Base controller. Code: class MY_Controller extends CI_Controller{ Then in each of your controllers use the base controller. That way when you need to update the syntax, you can do it in your base controller, and not every controller. Also, try search in replace in your editor. Most decent text editors will do a search and replace in folders. The controller syntax is the only other major change in CI2.0 syntax. If you have extend some system libaries, some of those just need to be moved from /application/libraries to /application/core. Took me about 10 mins or so do as well for each site. 404 page not found... - El Forum - 08-04-2011 [eluser]Aken[/eluser] Questions and suggestions: 1) Do your PHP versions differ between your laptop and the server? Which constructor you use will depend on the PHP version. If they don't match, you should make your laptop match the production server as close as possible so that there are no surprises. 2) Make sure you code your class names and such properly. Again, capitalization. Code: class Portfolio extends Controller { 3) Like LuckyFella73 suggested, you want to avoid your CI controller names conflicting with actual folders. 4) Extending on #3, a properly set up .htaccess file will be able to tell the difference between an existing directory or not. Search around for alternative .htaccess recommendations besides what you have already. 404 page not found... - El Forum - 08-04-2011 [eluser]LuckyFella73[/eluser] @ Aken Quote:4) Extending on #3, a properly set up .htaccess file will be able to tell the difference between an existing directory or not. Does that mean you can have a folder with the same name as a controller when setting up the htaccess the right way? A while ago I searched for hours to find such an .htaccess example but couldn't find one. Could you provide one? Would be really nice to have 404 page not found... - El Forum - 08-04-2011 [eluser]Aken[/eluser] Here is a very basic .htaccess that I recommend for CodeIgniter. It will default to an existing file or directory if one exists before sending it through CodeIgniter's index.php. You might also want to look at http://www.html5boilerplate.com and their .htaccess for additional rules that will help your application. Code: <IfModule mod_rewrite.c> 404 page not found... - El Forum - 08-04-2011 [eluser]LuckyFella73[/eluser] Tryed that .htaccess but it does not work for me. I did a test with a fresh CI installation, created a folder called "welcome" and placed an index.html in that folder. When calling http://localhost/ht/welcome/ (where "ht" is my test folder in htdocs) I get the index.html not the welcome/index controller/method. 404 page not found... - El Forum - 08-04-2011 [eluser]Aken[/eluser] Yes that's the exact functionality it should have. I thought that's what you were requesting. The .htaccess says "If this URL does not contain a valid directory or file, rewrite the URL to this...". Existing files and directories will take priority. If you want your CI controllers to always take priority over any existing directories that are accessible via the same URL, just remove this part of the .htaccess: Code: RewriteCond %{REQUEST_FILENAME} !-d I'd still recommend finding an alternative to that (existing files and directories should always be higher priority in my opinion), but I suppose there may be situations where it's desired. 404 page not found... - El Forum - 08-04-2011 [eluser]LuckyFella73[/eluser] Hmm, maybe I'm doing something wrong though commenting out a line isn't that hard But that still doesn't work for me. Quote:I’d still recommend finding an alternative to that (existing files and directories should always be higher priority in my opinion) The last time I had this kind of conflict I had a controller "downloads" and a folder "downloads" containing pdf files and so on. When calling the controller of course I was sent to the directory - what in my opinion makes no sense as long as I don't specify a file inside the "downloads" folder. Would be good to have a rule that can differentiate between that. But never mind - it's not a big deal to choose different controller/directory names Thanks for trying to help anyway! 404 page not found... - El Forum - 08-04-2011 [eluser]Ivar89[/eluser] wow late replay for me(very busy at work) I don't have my controllers in separate folder just in the controller folder If I copy CI to another computers localhost it does work so it really the laptop. I made a base controller and that works so then its easy to update CI, and I'll do that soon Yet no matter what I do it still won't work on my laptop 404 page not found... - El Forum - 08-04-2011 [eluser]pickupman[/eluser] [quote author="Ivar89" date="1312471242"]Yet no matter what I do it still won't work on my laptop[/quote] I had this happen to me once, and then it hit me. I had created an alias for a directory that I had longed forgot about. Double check your apache aliases and make sure you don't have a conflict there. One question we have forgot to ask you is it a CI 404 error (gray box with red letters), or an Apache 404? 404 page not found... - El Forum - 08-04-2011 [eluser]Mirge[/eluser] [quote author="Aken" date="1312468552"]Yes that's the exact functionality it should have. I thought that's what you were requesting. The .htaccess says "If this URL does not contain a valid directory or file, rewrite the URL to this...". Existing files and directories will take priority. If you want your CI controllers to always take priority over any existing directories that are accessible via the same URL, just remove this part of the .htaccess: Code: RewriteCond %{REQUEST_FILENAME} !-d I'd still recommend finding an alternative to that (existing files and directories should always be higher priority in my opinion), but I suppose there may be situations where it's desired.[/quote] -d flag is for directories -f flag is for files |