Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/282.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_.htaccess_Codeigniter - Fatal编程技术网

Php Codeigniter页面路由不工作

Php Codeigniter页面路由不工作,php,.htaccess,codeigniter,Php,.htaccess,Codeigniter,我正在使用CodeIgniter 3,在我的开发环境中使路由器工作时遇到问题。文件的相关部分: site/.htaccess文件: RewriteEngine on RewriteCond $1 !^(index\.php|images|robots\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php/$1 [L] site/ap

我正在使用CodeIgniter 3,在我的开发环境中使路由器工作时遇到问题。文件的相关部分:

site/.htaccess文件:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L] 
site/application/config/routes.php文件:

$route['default_controller'] = 'auth/login';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
$route['page/(:any)'] = 'page/view/$1';
site/application/config/config.php:

$config['base_url'] = 'http://localhost/~me/site/';
$config['index_page'] = '';
site/application/controllers/Page.php

<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Page extends CI_Controller {
public function view($page = 'about')
{
    if (!$this->ion_auth->logged_in()) {
        redirect('auth/login');
    }
    if ( ! file_exists(APPPATH.'/views/page/'.$page.'.php')) {
        show_404();
    }
    $this->load->view('templates/header');
    $this->load->view('page/'.$page);
    $this->load->view('templates/footer');
}
但是,我想使用的是:localhost/~me/site/page/about,它提供:

The requested URL /index.php/page/about was not found on this server
我在localhost/~me/site/page/view/about中遇到同样的错误

因此,似乎只有当我: 显式调用index.php,或 b打不分机的路线


任何帮助都将不胜感激

在.htaccess文件中尝试此操作

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L,QSA]

您是否已将AllowOverride All指令添加到Apache配置文件或虚拟主机配置文件中?

我以前尝试过此文件配置,但在服务器备份后,我将使用当前配置重试。在关机/重启后,我昨天做的一些编辑显然打乱了我的访问。我已经完成了操作系统的完全重新安装,我还遇到了其他异常情况。服务器似乎再次正常运行,但我仍然体验到相同的结果。上面推荐的.htaccess文件只导致将错误消息中的引用更改为/index.php,而不是/index.php/page/about。此时,我想知道这是否是OS X Yosemite和/或Apache 2.4的问题。
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L,QSA]