超链接和图像不显示

时间:2015-11-03 11:13:45

标签: php codeigniter xampp

我在xampp中使用codeigniter,在我的代码中有两个问题

超链接不起作用我以不同的方式尝试了许多方法,但没有工作

<a href="<?php  base_url();?> Login_v.php">Log in</a>

也无法显示图像

<img src="images/login.jpg" width="150" height="40" /> 

我认为我的.htaccess错误

<IfModule mod_rewrite.c>

    RewriteEngine On
    RewriteBase /helloworld/

    # Disable rewrite for valid directory/files    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d 

    #map all request urls to a specific controller method
    RewriteRule ^(.*)$ index.php?/{controller}/{method}/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule> 

请有人帮助我

1 个答案:

答案 0 :(得分:1)

这应该是

<img src="images/login.jpg" width="150" height="40" /> 

更改为

<img src="<?php echo base_url()?>images/login.jpg" width="150" height="40" /> 

并加载文件应链接到控制器方法 d

<a href="<?php  base_url();?> Login_v.php">Log in</a> # Not works

解决方案

<a href="<?php  base_url();?>controller_name/function_name">Log in</a>

控制器内部

public function function_name()
{
    $this->load->view("login_v");
}

在视图中

创建/移动Login_v.phpapplication/view

相关问题