Search code examples
phpcodeigniterurlurl-routing

how to remove codeigniter functions from base url when routing


I routed my controller function and suddenly the function name is added to base URL, how can I remove this?

 $route['editblog/(:num)']='Code/editblog/$1';

Then all of the sudden edit blogs are added to base URL and my external files are showing an error.

<script src="assests/vendor/slick/slick.min.js">

It shows:

<script src="editblog/assests/vendor/slick/slick.min.js">

Please help me, help will be highly appreciated!


Solution

  • You need to verify 1 things:

    • application/config.php $config['base_url'] = 'application/path/'; like http://example.com/ or http://localhost/applicationName/

    Now you should use urls like

    • base_url('assets/js/filename/js');
    • base_url('controller/action/parameters');

    In this way, it will generate correct urls.