有很多类似的帖子,但都没有解决我的问题。
当我在href
属性中使用base_url()
时,我得到了错误的url-http://localhost/admin/localhost/admin/insertData
。
我的config.php
脚本->$config['base_url'] = 'localhost';
,而且我已经从url中删除了index.php
。
因此,我们可以看到,<a href="<?=base_url();?>admin/insertData"></a>
解决方案只将当前的url
与href
属性连接起来。
我也试过设置$config['base_url'] = '';
,但后来我得到了:http://::1/admin/insertData
这个解决方案也不起作用。
.htaccess文件
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index.php|resources|assets|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
有什么建议可以解决吗?
我不使用base_url();除了我迫切需要它。我留下空的$config['base_url'] = '';
,我使用根路径,比如:
<a href="/admin/insertData"></a>