Search code examples
phpcodeigniterurlroutes

how to modify routes in codeigniter


help me with this.

Take example: I have this normal url "localhost/CI/index.php/base/storeurl".

How can I let Codeigniter know to look for "localhost/CI/storeurl".

I have a function named index and it accepts a parameter storeURL in the Base.php class. Help me with this. Thanks in advance.


Solution

  • I've finally found what I was looking for. Here is how my code looks like in routes.php.

    /* Custom Routes. */
    // Store Normal Pages.
    $route['home/(:any)'] = "base/home/$1";
    $route['about/(:any)'] = "base/about/$1";
    $route['services/(:any)'] = "base/services/$1";
    $route['contact/(:any)'] = "base/contact/$1";
    $route['feedback/(:any)'] = "base/feedback/$1";
    
    // CategoryPage.
    $route['category/(:any)/(:num)'] = "base/category/$1/$2";
    // ProductPage.
    $route['product/(:any)/(:num)'] = "base/product/$1/$2";
    
    
    // For Main Home Page.
    $route['(:any)'] = "base/home/$1";
    

    I really Appreciate everyone who helped me solving this problem. Thank You Guys.