Welcome Guest, Not a member yet? Register   Sign In
I want to use username on my url, how can i ?
#1

[eluser]Unknown[/eluser]
hello all

I am a new study of CI and I want to use username on my url like

http://localhost/mywebsite/charler

and make a mod rewrite to http://localhost/mywebsite/user/getuser/charler
after I study how to remove index.php with create a .htaccess file like

Code:
RewriteEngine On

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

so I modify a little bit to
Code:
RewriteEngine On

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

It doesn't work just give me 404.
Then I replace [L] with [R, L], It's work but i don't want it that way. I'm very confusing right now. I just want to know why and how I can get what I want.

thanks in advance.
sorry for my bad english.
#2

[eluser]vbsaltydog[/eluser]
http://ellislab.com/codeigniter/user-gui...uting.html
#3

[eluser]Unknown[/eluser]
wow ... Interesting It's work !!!!
don't change .htaccess just change route[404]

Code:
$route['404_override'] = 'user/getuser';

and use
Code:
$this->uri->segment(1)
to retrieve username

I spent almost two days to figure it out.

Thank you very much, vbsaltydog
#4

[eluser]Aken[/eluser]
404_override is the route for what controller/method should be displayed in the event of a 404. Change this route to a specific method meant to display a 404 error. Add a new route for your usernames.




Theme © iAndrew 2016 - Forum software by © MyBB