CodeIgniter Forums
Url rewriting - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: Url rewriting (/showthread.php?tid=20421)

Url rewriting - El Forum - 07-09-2009

Hi everyone, I have some problems with code igniter url rewriting.
I want my users have personnals urls like that:
I have set DNS wildcard and in my vhost configuration.

My problem is for Rewrite rules.

Usually (without CI), I do something like that:
RewriteRule (.*) index.php?user=%1 [L]. So, was the same as

But with CI, it's not possible to do the same because i can't pass variable with index.php?variable=whatever

If I do something like RewriteRule (.*) [L], it works but it redirects and I want to keep in adress bar instead of

Does someone have any idea to do that?
Thanks a lot :-)

Url rewriting - El Forum - 07-09-2009

Doing it the first way, you need to make sure you have query strings enabled. If you don't need to use query strings for your entire site, I'd suggest sticking to your second method. If you want it to redirect internally, you need to omit the URL, so:
RewriteRule (.*) index.php?/user/%1 [L]

should probably do what you want. Adding the URL makes the redirect external, which can be really handy for confirming that it's rewriting the URL as you'd expect it to.