首页 文章

codeigniter:锚链接不在localhost中工作,但索引页面执行正常

提问于
浏览
0

我从网络服务器上下载了一个旧网页 . 现在我重新设计所有页面 . 测试链接时返回localhost内容页面 . 但它在Web服务器中工作正常 .

在localhost索引页面工作正常,但从索引页链接不起作用 . 点击链接时,网址显示就像

http://localhost/sitename/site/index

主页中的锚码是:

<?php echo  anchor(base_url().'site/index','Home','class="header"');?>

在config.php中

$config['base_url'] = 'http://localhost/sitename/';
$config['index_page'] = '';

在controller(site.php)中:

class Site extends CI_Controller    
{
public function __construct()
{
    parent::__construct();
    $this->load->helper('url');
    $this->load->helper('form');    
    $this->load->helper('html');        
}

public function index()
{       
    $this->load->view('site/home');     
}
}

www / site-folder-name上的.htaccess页面

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>

如果你想要任何其他细节,我会给你....

1 回答

  • 0

    修改你的Htaccess

    RewriteEngine on
    RewriteBase /project_name
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond $1 !^(index\.php|images|robots\.txt)
    RewriteRule ^(.*)$ index.php/$1 [L]
    

相关问题