CodeIgniter 404 Page Not Found, but why?

前端 未结 11 2348
Happy的楠姐
Happy的楠姐 2020-12-11 14:48

I am using CodeIgniter for two applications (a public and an admin app). The important elements of the document structure are:

/admin
/admin/.htaccess
/admin         


        
相关标签:
11条回答
  • 2020-12-11 15:30

    Leaving this answer here for others who ran into my situation.

    My codeigniter app was working fine in localhost/WAMP, but was unable to route and produced 404 not found errors when pushing to an AWS EC2 instance. My issue was solved from the answer from HERE htaccess works in localhost but doesn't work in EC2 instance

    (route to my admin page) {domain}/admin was producing 404

    the /etc/httpd/conf/httpd.conf file needs to be modified.

    -after every instance of "DocumentRoot "/var/www/html"" (2 places) "AllowOverride None" needed to be changed to "AllowOverride All".

    Restarted the EC2 instance from the AWS dashboard.

    {domain}/admin is now accessible and working as intended.

    hope this helps someone else like it helped me!

    0 讨论(0)
  • 2020-12-11 15:32

    In my case I was using it on localhost and forgot to change RewriteBase in .htaccess.

    0 讨论(0)
  • 2020-12-11 15:33
    1. Change your controller name first letter to uppercase.
    2. Change your url same as your controller name.

    e.g:

    Your controller name is YourController

    Your url must be:

    http://example.com/index.php/YourController/method

    Not be:

    http://example.com/index.php/yourcontroller/method

    0 讨论(0)
  • 2020-12-11 15:35

    Your folder/file structure seems a little odd to me. I can't quite figure out how you've got this laid out.

    Hello I am using CodeIgniter for two applications (a public and an admin app).

    This sounds to me like you've got two separate CI installations. If this is the case, I'd recommend against it. Why not just handle all admin stuff in an admin controller? If you do want two separate CI installations, make sure they are definitely distinct entities and that the two aren't conflicting with one another. This line:

    $system_folder = "../system";
    $application_folder = "../application/admin"; (this line exists of course twice)
    

    And the place you said this exists (/admin/index.php...or did you mean /admin/application/config?) has me scratching my head. You have admin/application/admin and a system folder at the top level?

    0 讨论(0)
  • 2020-12-11 15:35

    I had the same issue after migrating to a new environment and it was simply that the server didn't run mod_rewrite

    a quick sudo a2enmod rewrite then sudo systemctl restart apache2

    and problem solved...

    Thanks @fanis who pointed that out in his comment on the question.

    0 讨论(0)
提交回复
热议问题