【问题标题】:Unable to access url without index.php in CodeIgniter projectCodeIgniter 项目中没有 index.php 无法访问 url
【发布时间】:2021-12-08 03:39:59
【问题描述】:

我正在尝试在本地设置 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]

route.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'] = '';

【问题讨论】:

    标签: php .htaccess codeigniter redirect


    【解决方案1】:

    这是我在 htdocs 中使用的,你可以在你的项目中尝试:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-04
      • 2015-03-01
      • 2019-02-05
      • 1970-01-01
      • 2019-03-17
      • 2013-08-09
      • 2012-12-27
      • 1970-01-01
      相关资源
      最近更新 更多