Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.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
URL重定向到.Htaccess不';不能在Php Codeigniter中工作_.htaccess_Codeigniter_Url Rewriting - Fatal编程技术网

URL重定向到.Htaccess不';不能在Php Codeigniter中工作

URL重定向到.Htaccess不';不能在Php Codeigniter中工作,.htaccess,codeigniter,url-rewriting,.htaccess,Codeigniter,Url Rewriting,我想知道,当我输入localhost/projectname/index.html时,它将重定向到 http://localhost/service/welcome/index 为此,我将其写入.htaccess,但它不起作用 <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.

我想知道,当我输入localhost/projectname/index.html时,它将重定向到

http://localhost/service/welcome/index
为此,我将其写入.htaccess,但它不起作用

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

Redirect /index.html http://localhost/service/welcome/index

重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php/$1[L]
重定向/index.htmlhttp://localhost/service/welcome/index

我该怎么做呢?

在codeigniter中,URL中没有文件在调用。Codeigniter所做的就是使用MVC结构来渲染视图

如果您访问根文件夹(index.html或index.php)上的任何内容,它也会重定向到应用程序文件夹。然后默认控制器被触发

cz在根目录中有文件调用
index.php
,您可以看到

$application_folder = 'application';
$system_path = 'system';
你可以看看这个

  • 路由-
    config/routes.php
  • 控制器-
    controller/
  • 型号-
    model/
  • 查看-
    view/
  • 我们使用
    .htaccess
    删除URL中的
    index.php

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

    里面没有重定向选项?那么我如何重定向或触发它?重定向什么??我们使用.htaccess删除url中的index.php我想在url中写入localhost/projectname/index.html时,它会转到主控制器和索引操作它如何确保此url请求转到主控制器和索引操作
    /*
    
      |--------------------------------------------------------------------------
    
      | URL suffix
    
      |--------------------------------------------------------------------------
    
      |
    
      | This option allows you to add a suffix to all URLs generated by CodeIgniter.
    
      | For more information please see the user guide:
    
      |
    
      | http://codeigniter.com/user_guide/general/urls.html
    
     */
    $config['url_suffix'] = '';