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

时间:2018-11-06 10:01:51

标签: php codeigniter url url-routing

我路由了控制器函数,然后突然将函数名添加到基本URL中,如何删除它?

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

然后将所有突然的编辑博客添加到基本URL,并且我的外部文件显示错误。

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

它显示:

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

请帮助我,我们将不胜感激!

3 个答案:

答案 0 :(得分:0)

您应该将URL更改为:

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

实际上base_url是在您的applications/config.php文件中设置的。 -> config['base_url']。它必须包含斜杠

答案 1 :(得分:0)

您需要验证1件事:

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

现在您应该使用

这样的网址
  • base_url('assets / js / filename / js');
  • base_url('controller / action / parameters');

通过这种方式,它将生成正确的网址。

答案 2 :(得分:0)

在您的配置文件中:

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

当您调出 base_url()时。您可以使用此:

fatal: [prod-operator]: FAILED! => {"failed": true, "msg": "The conditional check 'inventory_hostname not in groups['control']['vms']' failed. The error was: error while evaluating conditional (inventory_hostname not in groups['control']['vms']): Unable to look up a name or access an attribute in template string ({% if inventory_hostname not in groups['control']['vms'] %} True {% else %} False {% endif %}).\nMake sure your variable name does not contain invalid characters like '-': argument of type 'StrictUndefined' is not iterable\n\nThe error appears to have been in '/root/micks-ci-setup/production/virtual_machine/create-vm.yml': line 29, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n  - name: Create Production VM\n    ^ here\n"}