Stefan Stanković
Stefan Stanković

Reputation: 636

CodeIgniter URI routing: remove route segment from base URL

How do I remove a route segments from my base URL? For instance, I have these routes in my routes.php:

$route['default_controller'] = 'main_controller';
$route['users'] = 'user_controller';
$route['user/(:num)'] = 'main_controller/user/$1';

They all get routed normally, but in the view called by the user() method all of the generated links (for .js, .css, .png files, etc...) have user/ inserted betweem base URL localhost/domain_name and file path (e.g. css/style.css), so all of those links (as you would expect) return 404 and the page isn't formatted properly.

If you need more info on the code in question, just comment what you need and I'll add it. Thanks in advance.

EDIT: If it's any help, echo base_url(); in the view prints out http://localhost/domain_name/.

Upvotes: 1

Views: 1083

Answers (1)

Gaurav
Gaurav

Reputation: 442

add base_url before the script and css files. and specify the folder in which is kept.Like we have style.css file in assets/css folder

<?php echo base_url('assets/css/style.css'); ?>
Or 
<?php echo base_url().'assets/css/style.css'; ?>

Upvotes: 3

Related Questions