CyberJunkie
CyberJunkie

Reputation: 22674

Codeigniter all URLs go to default controller

I'm testing my php app built with Codeigniter on local host (wamp). In Firefox all my URLs go to my default controller unless I add a trailing slash.

e.g. site.com/controller/method/

Even methods not expecting a third URI segment are redirected. Does anyone know the reason behind this?

Update

application/config/routes.php

$route['default_controller'] = "pages"; //loads homepage view
$route['404_override'] = '';

I'm not using .htaccess on localserver

Upvotes: 1

Views: 1075

Answers (2)

Ts8060
Ts8060

Reputation: 1070

Change your URL like this. This is default URL.

site.com/index.php/controller/method/

If you are configured .htaccess

site.com/controller/method/ this url is correct

Upvotes: 1

user1440875
user1440875

Reputation:

You mentioned you are not using .htaccess but without rewriting /controller/method/ into appropriate path your application will fail. Usual .htaccess file for a CodeIgniter application should contain at least the following configuration for rewriting

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

Upvotes: 2

Related Questions