Sathya Baman
Sathya Baman

Reputation: 3515

codeiginiter always shows 404 error ubuntu 14.04

I done a project using codeiginiter in windows(XAMPP), now i changed my OS to UBUNTU 14.04 and i have installed LAMP and LAMP works fine.

i copied my project files to /var/www/html and changed all the configurations to ububtu

$config['base_url'] = 'http://localhost/lankaproperty/';

$config['index_page'] = 'index.php';

routes

$route['default_controller'] = 'welcome';
$route['404_override'] = 'home/error_404';
$route['500_override'] = 'home/error_500';
$route['translate_uri_dashes'] = FALSE;

.htaccess

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php?/$0 [PT,L] 

i have also changed all the file permissions to 755..

when i try the default controller like this http://localhost/lankaproperty/ it works fine..

but none of the other controller is working

http://localhost/lankaproperty/home

http://localhost/lankaproperty/index.php?/home

i get the error.

` 404 Page Not Found

The page you requested was not found. ` can someone help me to fix this issue tnx..

etc/apache2/apache2.conf

    # Sets the default security model of the Apache2 HTTPD server. It does
    # not allow access to the root filesystem outside of /usr/share and /var/www.
    # The former is used by web applications packaged in Debian,
    # the latter may be used for local directories served by the web server. If
    # your system is serving content from a sub-directory in /srv you must allow
    # access here, or in any related virtual host.
    <Directory />
        Options FollowSymLinks
        AllowOverride All
        Require all denied
    </Directory>

    <Directory /usr/share>
        AllowOverride All
        Require all granted
    </Directory>

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

sites-enabled/000-default.conf

    <VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html



        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
    </VirtualHost>

    # vim: syntax=apache ts=4 sw=4 sts=4 sr noet

sites-avalible/000-default.conf

    <VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html



        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
    </VirtualHost>

    # vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Upvotes: 2

Views: 2262

Answers (2)

Nitesh Gupta
Nitesh Gupta

Reputation: 108

Replace the value from these two section in config file.

$config['base_url'] = 'http://localhost/lankaproperty/';
$config['index_page'] = 'index.php';

To

$config['base_url'] = '';
$config['index_page'] = '';

Hope is usefull for u.

Upvotes: 1

Tpojka
Tpojka

Reputation: 7111

Try code from documentation:

//config.php
$config['index_page'] = '';

//.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Upvotes: 0

Related Questions