CodeIgniter Forums

Full Version: url friendly, redirect users to other users profile by usename
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everyone 
is it possible in codeigniter to redirect users by username
in my site when users are logged in the url is like this: http://localhost/friendmiiDemo/posts when they are on their profiles the url is like this: 

i want when users type other username on url like this: http://localhost/friendmiiDemo/abelo3088 be redirected to this users profile, so inside profile view i putted .htaccess file with this code:[url=http://localhost/friendmiiDemo/posts][/url]

RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ profile?u=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ profile?u=$1

but it just wont work i don't know if is codeigniter or htccess.
if you can help or there is any other way i could do this please help
Thanks in advance.
You can replace http://localhost/friendmiiDemo/profile?u=abelo3088 by http://localhost/friendmiiDemo/profile/abelo3088 by passing the username as a parameter to your method like this:

PHP Code:
class ProfileController extends CI_Controller
    public function profile ($username NULL)
        if ( ! empty($username))
            // Display user's profile
            // Show error or redirect somewhere else...