1
votes

Ive started a codeigniter site. my default controller is $route['default_controller'] = "login"; in routes.php

and my base URL is $config['base_url'] = 'http://digimed.net/sandbox/'; in config.php

Scenario A I type http://digimed.net/sandbox/ in teh URL bar I get the index method of the login controller as expected.

Scenario B I type something like http://digimed.net/sandbox/login I get a 404 error when I expected the same result as in scenario A.

In fact I cannot access any function in the login controller. I get a 404 error every time.

Is there something I need to change in routes or congig?

thanks

1
have you set up the rewrite rules for the webserver?Karoly Horvath
uhm, not specifically no. how do I do that?Kevin Bradshaw
try to point your browser to digimed.net/sandbox/index.php/login if it works as excepted it means you are miss the rewrite rules, see Kevin`s answerFrancesco Laurita

1 Answers

0
votes

in case anyone is interested I solved the problem by adding the following .htaccess file in the website route directory ( where the codeigniter route directory lives )

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /system_admin

#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#This last condition enables access to the images and css folders, and the robots.txt file
#Submitted by Michael Radlmaier (mradlmaier)
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin

ErrorDocument 404 /index.php
</IfModule>