我希望包含index.php
和index.php
从我的URI中排除,以便在我的网站上顺利运行。我需要它因为uploadify不工作,它给我一个HTTP错误。
如果我改变了这个
,它会起作用 $config['uri_protocol'] = 'AUTO';
到这个
$config['uri_protocol'] = 'QUERY_STRING';
,但整个系统运行不正常。
答案 0 :(得分:0)
对于您的资源,首先,在config.php
上将$config['base_url']
设置为您的网站网址。
然后,当链接到您不想要index.php的资产时,只需使用函数base_url
<?php echo base_url("assets/uploadify/uploadify.swf"); ?>
// Generates http://URL/assets/uploadify/uploadify.swf
答案 1 :(得分:0)
按照上面Indranil的评论中的链接,通过修改.htaccess
文件从URI中删除index.php。
这是再次提供的地址供参考:
http://codeigniter.com/user_guide/general/urls.html
请记住,这可能因主机需要格式化而在主机之间有所不同,因此请使用您的托管服务进行跟进。大多数情况下,通常会有指南向您展示如何正确配置它。
我也想知道你是如何使用链接的,但我会继续解释我认为你可能会发生什么。如果你在CodeIgniter中使用URL Helper进行任何类型的链接/锚点或redirect()
,那么请确保使用正确的函数来执行这些操作。这就是我的意思:
site_url()
函数/方法将始终在URI中包含index.php。以下是使用网站名称http://example.com
作为您网站的域名的示例。
<?php echo site_url('home') ?>
将变为http://example.com/index.php/home
虽然base_url()
函数/方法将始终排除index.php,除非您包含它。以下是使用网站名称http://example.com
作为您网站的域名的示例。
<?php echo base_url('home') ?>
将变为http://example.com/home
和
<?php echo base_url('index.php/home') ?>
将变为http://example.com/index.php/home
请注意,使用这些功能/方法仅在您正确修改.htaccess
文件后才有效。
以下链接可显示site_url()
和base_url()
函数之间的更深层差异。
http://codeigniter.com/user_guide/helpers/url_helper.html
我希望这有帮助!