Why codeIgniter show the requested URL was not found on this server?
Asked Answered
O

4

4

I want to ask. First of all, I will tell that I've develop an application use codeIgniter on my windows dekstop. And it clear and run completely.

But, after I move that project to debian server, it said :

The requested URL /index.php/Admin was not found on this server.

I want to ask, why I got an output like that? Eventhough I ran the same project with the same code. How can I do to fix this issue?

Thanks...

Ovation answered 11/10, 2015 at 6:14 Comment(3)
Did you done enough routing configuration for your applicationTumefacient
What version of codeigniter are you using?Peppy
First check $config['base_url'] and .htaccess file values.Thorlay
S
13

First of all enable mod_rewrite then restart apache2 using following commands:

sudo a2enmod rewrite
sudo service apache2 restart

then open apache conf file using command:

sudo gedit /etc/apache2/apache2.conf

uncomment below line if it is commented

AccessFileName .htaccess

then find these lines in apache2.conf

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted

here change the line AllowOverride None to AllowOverride All and save this file.

Now, your issue is resolved.

Socialism answered 25/1, 2017 at 21:47 Comment(2)
Been trying to figure out with a site without Codeigniter worked and another with Codeigniter didn't, and your answer solved the problem! Thank you so much! +1Womanhood
@JuOliveira Glad, it helped you.Socialism
T
0

Codelgniter URL example :

example.com/class/function/id/ 

So check your class name correct or not, And call url instead of Capital A - Admin to admin.

<?php (defined('BASEPATH')) OR exit('No direct script access allowed');

class Admin extends CI_Controller 
{

}  

Note: if you use codelgniter-3 version file name also must Should capital A. I mean Admin.php

Transmigrate answered 11/10, 2015 at 6:32 Comment(1)
I think the code is correct, because I also hosting it to another debian server and it's clear. But why in this server, I got output like that? I think that there is something about server configuration, do you know? Thanks....Ovation
R
0

First thing that you should know the debian is a Linux base server. So Its not like windows servers(XAMPP and WAMP).

So first of all consider about Letters. It means debian Sever is Case-Sensitive.

So check your naming conversation as well

Check these

  1. Controller class name class Admin extends CI_Controller
  2. Controller file name should be admin.php
  3. Check in routes.php. In routes $route['default_controller'] = "admin";
Rockery answered 11/10, 2015 at 6:32 Comment(6)
Controller file name should be Admin.php upper case in codeigniter 3Peppy
@wolfgang1983 there is no harm with file nameRockery
But that is what I have been told by the developers of codeigniter 3 because of some live servers. Works fine on localhost with lower case but when go to live that when may have issue.Peppy
@wolfgang1983 But i check. Its work with no harm still. Some how you may be correctRockery
See codeigniter.com/user_guide/installation/… "Starting with CodeIgniter 3.0, all class filenames (libraries, drivers, controllers and models) must be named in a Ucfirst-like manner"Ambrogio
@Ambrogio thanks for link. How ever OP question related to CI 2Rockery
M
0

after long searched I got the problem enable .htaccess file in apache by going /etc/httpd/conf/httpd.conf than search /var/www/html in that file after you got that line change AllowOverride None To All

for further information https://ubiq.co/tech-blog/enable-mod_rewrite-apache-centos/

Malacology answered 3/6, 2022 at 0:11 Comment(1)
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From ReviewIdona

© 2022 - 2024 — McMap. All rights reserved.