views:

145

answers:

1

How can I change this url: http://localhost/index.php/Department/2

to this one: http://localhost/index/Department/2

Thanks.

+6  A: 

Try this rule:

RewriteRule ^index/(.*) index.php/$1

And if you want to strip the index/ too, try this:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !^index\.php$ index.php%{REQUEST_URI}
Gumbo
Thanks but it does not work, I get file not found.
rtacconi
Try to set the `R` flag to enforce an external redirect to see if and where the request is redirected to.
Gumbo
Oh, I hope you didn’t forget the obligatory `RewriteEngine on` to enable mod_rewrite.
Gumbo
I have tried;RewriteRule ^index/(.*) index.php/$1 -R but I get an internal server error. RewriteEngine is on.
rtacconi
Flags are written as comma separated list in brackets. So: `RewriteRule ^index/(.*) index.php/$1 [R]`
Gumbo