Codeigniter redirect repeats controller name in URL
Posted
by Obay
on Stack Overflow
See other posts from Stack Overflow
or by Obay
Published on 2010-06-12T20:30:42Z
Indexed on
2010/06/12
20:32 UTC
Read the original article
Hit count: 332
This is my controller:
class Timesheet extends Controller {
...
function index() {
//loads view with a form that submits to "timesheet/change_date"
}
function summary() {
//loads view with a form that submits to "timesheet/change_week"
}
function change_date() {
...
redirect('timesheet');
}
function change_week() {
...
redirect('timesheet/summary');
}
...
}
The first form is located at http://localhost/dts/index.php/timesheet
and when I submit the change_date form, it correctly goes thru the change_date() function and re-loads http://localhost/dts/index.php/timesheet
correctly.
However, the second form is located at http://localhost/dts/index.php/timesheet/summary
, and when I submit the change-week form, it goes thru the change_week() function but goes to http://localhost/dts/index.php/timesheet/timesheet/change_week
. Notice the word timesheet
is repeated. When I submit the form again, another timesheet
is added.
What's wrong and how do I improve my code?
My .htaccess is below:
RewriteEngine on
RewriteCond $1 !^(index\.php|webroot|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
© Stack Overflow or respective owner