Welcome Guest, Not a member yet? Register   Sign In
Removing the method name from urls
#1

[eluser]mikegeorgeff[/eluser]
I have a url like this: mysite.com/members/member/user_name

How would I remove the second segment (member) from the url so I end up with this:
mysite.com/members/user_name

here is my controller code

Code:
<?php
if (! defined('BASEPATH')) exit('No direct script access');

class Members extends CI_Controller {

    //php 5 constructor
    function __construct()
    {
        parent::__construct();
        //$this->output->enable_profiler(TRUE);
    }
        
        function index()
        {
           //code for index
        }

    /* Profiles */
    function member($slug)
    {
        $data['title'] = 'Profile';
        $data['head'] = 'profile_head';
        $data['member'] = $this->MUsers->getUser($slug);
        $data['articles'] = $this->MArticles->getAllByUserSlug($slug);
        $data['main'] = 'profile';
        $this->load->view('template', $data);
    }
}
#2

[eluser]Basketcasesoftware[/eluser]
Read this section of the User Guide.
http://ellislab.com/codeigniter/user-gui...s/uri.html

I'd throw you a code sample but I'm not really sure what you want to with this.
#3

[eluser]mikegeorgeff[/eluser]
I've read that section of the guide several times. I just want to remove the action (the controllers function) from the url so this:
mysite.com/members/member/user_name

would turn into this:
mysite.com/members/user_name
#4

[eluser]Rok Biderman[/eluser]
Well, that is doable with routes like this
Code:
$route['member/index'] = "members/index";
$route['member/(:any)'] = "members/member/$1";
but it raises the question (one that Basketcasesoftware asked as well) - why did you construct your application in a way that needs member method erased, but you can't put it in a index function? Bad carma, imho.




Theme © iAndrew 2016 - Forum software by © MyBB