代码点火器:锚链接在本地主机中不起作用,但索引页面执行正常


codeigniter : anchor link not working in localhost but index page executes fine

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

在本地主机索引页工作正常,但从索引页链接不起作用。单击链接时,URL 显示正常,例如

http://localhost/sitename/site/index

主页中的锚代码是:

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

在配置中.php

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

在控制器(站点.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');     
}
}

.htaccess page on www/site-folder-name

     <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>

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

修改你的 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]