php - CodeIgniter 项目中没有 index.php 无法访问 url
问题描述
我正在尝试在本地设置 CodeIgniter 项目。例如:http://fit.now/index.php/Admin/dashboard
如果我尝试访问其他 url 而不是主 url http://fit.now。然后它返回 404。
我的 .htaccess 文件代码
<IfModule authz_core_module>
Require all denied
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
路由.php 文件
$route['default_controller'] = 'Index';
$route['logout'] = 'login/logout';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
httpd-vhost.conf 文件
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/Admin/"
ServerName fitbit.now
</VirtualHost>
我的 config.php 文件
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$config['base_url'] = 'http://fitbit.now/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
$config['url_suffix'] = '';
$config['language'] = 'english';
$config['charset'] = 'UTF-8';
$config['enable_hooks'] = FALSE;
$config['subclass_prefix'] = 'MY_';
$config['composer_autoload'] = FALSE;
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
$config['enable_query_strings'] = FALSE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
$config['directory_trigger'] = 'd';
$config['allow_get_array'] = TRUE;
$config['log_threshold'] = 0;
$config['log_path'] = '';
$config['log_file_extension'] = '';
$config['log_file_permissions'] = 0644;
$config['log_date_format'] = 'Y-m-d H:i:s';
$config['error_views_path'] = '';
$config['cache_path'] = '';
$config['cache_query_string'] = FALSE;
$config['encryption_key'] = '';
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
//$config['sess_save_path'] = NULL;
$config['sess_save_path'] = sys_get_temp_dir();
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
$config['cookie_prefix'] = '';
$config['cookie_domain'] = '';
$config['cookie_path'] = '/';
$config['cookie_secure'] = FALSE;
$config['cookie_httponly'] = FALSE;
$config['standardize_newlines'] = FALSE;
$config['global_xss_filtering'] = FALSE;
$config['csrf_protection'] = FALSE;
$config['csrf_token_name'] = 'csrf_test_name';
$config['csrf_cookie_name'] = 'csrf_cookie_name';
$config['csrf_expire'] = 7200;
$config['csrf_regenerate'] = TRUE;
$config['csrf_exclude_uris'] = array();
$config['compress_output'] = FALSE;
$config['time_reference'] = 'local';
$config['rewrite_short_tags'] = FALSE;
$config['proxy_ips'] = '';
解决方案
这是我在我的 htdocs 中使用的,你可以在你的项目中尝试它:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
推荐阅读
- python - 为什么我的程序不会像我编写的那样过滤掉停用词和标点符号?(Python & NLTK)
- paypal - 如何进行多次付款
- python - “房间”类没有“对象”成员
- node.js - 不和谐音频播放器
- json - 格式化数组/对象时出现 Jq tsv 错误
- django - Django,自定义管理器,base_manager_name 和保存模型失败
- javascript - 为什么图像不显示在浏览器同步上?
- python-3.x - 运行 Pyinstaller exe 时出错(FileNotFoundError:没有这样的文件或目录)
- javascript - 将一系列 URL 字符串转换为 HTML 链接
- mysql - MYSQL 未知列但列存在 varchar 是时间戳