Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php codeigniter:锚链接在本地主机中不工作,但索引页执行良好_Php_Html_Codeigniter - Fatal编程技术网

Php codeigniter:锚链接在本地主机中不工作,但索引页执行良好

Php codeigniter:锚链接在本地主机中不工作,但索引页执行良好,php,html,codeigniter,Php,Html,Codeigniter,我从Web服务器下载了一个旧网页。现在我正在重新设计所有页面。在测试链接时,返回localhost内容页。但它在web服务器中运行良好 在本地主机中,索引页工作正常,但来自索引页的链接不工作。 当点击链接时,url显示良好,如 http://localhost/sitename/site/index 主页中的锚定代码为: <?php echo anchor(base_url().'site/index','Home','class="header"');?> 在controll

我从Web服务器下载了一个旧网页。现在我正在重新设计所有页面。在测试链接时,返回localhost内容页。但它在web服务器中运行良好

在本地主机中,索引页工作正常,但来自索引页的链接不工作。 当点击链接时,url显示良好,如

http://localhost/sitename/site/index
主页中的锚定代码为:

<?php echo  anchor(base_url().'site/index','Home','class="header"');?>
在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文件夹名称上的.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>
如果您需要任何其他详细信息,我将为您提供…

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

我认为这个问题可能是由于你的.htaccess或试图使你的$config['base_url']=;为什么我们需要htaccess,我尝试了$config['base_url']=;但同样的问题。它会将所有请求带到你的应用程序根index.php文件,而不是从它们的输出执行路由到你的url中指定的控制器和指定的方法。我现在也给出了htaccess,htaccess的内部是RewriteCond%{request_FILENAME}上的RewriteEngine-d RewriteCond%{REQUEST_FILENAME}\.php-f RewriteRule^.*$$1.php,但同样的问题在.htaccess中的RewriteEngine打开后,这一行RewriteBase/sitename可能会工作。
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]