[英]base_url in codeigniter not working,
I Have issue on base_url in codeigniter. 我在codeigniter中的base_url上有问题。 I googling to find a solution but no luck.
我谷歌上搜索解决方案,但没有运气。 I Hope this forum can help find the solution.
我希望这个论坛有助于找到解决方案。
my I issue is base_url not translated properly. 我的问题是base_url没有正确翻译。
this is my config.php 这是我的config.php
$config['base_url'] = 'http://192.168.1.181/asset_apps';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
this is my view : 这是我的看法:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Meta, title, CSS, favicons, etc. -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Login To Asset Management</title>
<!-- Bootstrap core CSS -->
<link href="<? echo base_url('gentelella/vendors/bootstrap/dist/css/bootstrap.min.css') ?>" rel="stylesheet">
<link href="<? echo base_url('gentelella/vendors/font-awesome/css/font-awesome.min.css') ?>" rel="stylesheet">
<link href="<? echo base_url('gentelella/documentation/css/animate.min.css') ?>" rel="stylesheet">
<!-- Custom styling plus plugins -->
<link href="<? echo base_url('gentelella/production/css/custom.css') ?>" rel="stylesheet">
<link href="<? echo base_url('gentelella/vendors/iCheck/skins/flat/green.css') ?>" rel="stylesheet">
<script src="<? echo base_url('gentelella/vendors/jquery/dist/jquery.min.js') ?>"></script>
</head>
<body style="background:#F7F7F7;">
<div class="">
<a class="hiddenanchor" id="tologin"></a>
<div id="wrapper">
<div id="login" class="animate form">
<section class="login_content">
<?php echo validation_errors(); ?>
<!-- <?php //echo form_open('application/controllers/verifylogin'); ?> -->
<form class="form-default" method="POST" action="<? echo base_url('verifylogin'); ?>">
<h1>Login Form</h1>
<div>
<input type="text" class="form-control" placeholder="Username" id="username" name="username" required=""/>
</div>
<div>
<input type="password" class="form-control" placeholder="Password" id="password" name="password" required=""/>
</div>
<!---<a class="btn btn-default submit" type ="submit" value ="Login" href="<?php //echo site_url('verifylogin') ?>">Log In</a> -->
<a><input class = "btn btn-default" align="center" type = "submit" value = "Login"></a>
<div class="clearfix"></div>
<br />
<div>
<h1><i class="fa fa-paw" style="font-size: 26px;"></i> Asset Management </h1>
<p>©2016 IT Department</p>
</div>
<!--<label for="username">Username:</label>
<input type="text" size="20" id="username" name="username"/>
<br/>
<label for="password">Password:</label>
<input type="password" size="20" id="passowrd" name="password"/>
<br/>
input type=<"submit" value="Login"/> -->
</form>
</section>
</div>
</div>
</div>
</body>
</html>
But When I run it on the browser and view page source, the base_url not translated or change to the base_url that I set on config. 但是当我在浏览器上运行它并查看页面源时,base_url没有翻译或更改为我在config上设置的base_url。
and when I click the link on th view page source error occured : 当我点击视图页面上的链接时出现源错误:
Forbidden 被禁止
You don't have permission to access /asset_apps/< on this server. 您无权访问此服务器上的/ asset_apps / <。
and the link on a toolbar like this : 以及工具栏上的链接如下:
http://192.168.1.181/asset_apps/%3C?%20echo%20base_url(%27gentelella/vendors/bootstrap/dist/css/bootstrap.min.css%27)%20?%3E http://192.168.1.181/asset_apps/%3C?%20echo%20base_url(%27gentelella/vendors/bootstrap/dist/css/bootstrap.min.css%27)%20?%3E
Please Help. 请帮忙。
Thank you in Advance. 先感谢您。
Best Regards, 最好的祝福,
Dian 典
Did you check that short tag is allowed or not by PHP? 您是否通过PHP检查是否允许使用短标签?
You can use full tags so there will be no problem in future 您可以使用完整标签,以便将来不会出现问题
<?php echo base_url('url'); ?>
Also add last extra /
in following 另外添加最后一个
/
以下
$config['base_url'] = 'http://192.168.1.181/asset_apps/';
First of all the php tags should be like this <?php echo base_url(); ?>
首先,php标签应该像这样
<?php echo base_url(); ?>
<?php echo base_url(); ?>
and not like this <? echo base_url(); ?>
<?php echo base_url(); ?>
而不喜欢这个<? echo base_url(); ?>
<? echo base_url(); ?>
Secondly, you must make sure that you have loaded the url helper 其次,您必须确保已加载url帮助程序
You can autoload url helper by editing autoload.php in the config directory like this 你可以通过编辑配置目录中的autoload.php来自动加载url helper
$autoload['helper'] = array('url','form');
Hope this will help you. 希望这会帮助你。
In order to use base_url(), you must first have the URL Helper loaded. 要使用base_url(),必须首先加载URL Helper。 This can be done either in application/config/autoload.php (on or around line 67):
这可以在application / config / autoload.php(在第67行或附近)完成:
$autoload['helper'] = array('url');
Or, manually:
$this->load->helper('url');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.