简体   繁体   English

路由时如何从基本url中删除codeigniter函数

[英]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? 我路由了控制器函数,然后突然将函数名称添加到基本URL中,如何删除它?

 $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. 然后,所有突然的编辑博客都添加到基本URL,并且我的外部文件显示错误。

<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! 请帮助我,我们将不胜感激!

You should change your URL's to: 您应该将网址更改为:

<script src="<?php echo base_url('assests/vendor/slick/slick.min.js'); ?>">

Actually base_url is set in your applications/config.php file. 实际上base_url是在您的applications/config.php文件中设置的。 -> config['base_url'] . -> config['base_url'] It MUST include trailing slash 必须包含斜线

You need to verify 1 things: 您需要验证1件事:

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

Now you should use urls like 现在您应该使用类似

  • base_url('assets/js/filename/js'); BASE_URL( '资产/ JS /文件名/ JS');
  • base_url('controller/action/parameters'); BASE_URL( '控制器/动作/参数');

In this way, it will generate correct urls. 这样,它将生成正确的URL。

in your config file: 在您的配置文件中:

$config['base_url'] = ' http://test.com '; $ config ['base_url'] =' http://test.com ';

when you call out the base_url() . 当您调出base_url()时 You can use this : 您可以使用:

<script src="<?= base_url().'/assests/vendor/slick/slick.min.js'; ?>">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM