代码点火器重定向页面无法按预期工作

时间:2018-08-02 04:02:30

标签: codeigniter redirect model-view-controller

Sub test()

    Dim ws1 As Worksheet
    Dim fr As Long, c As Long

    Set ws1 = Worksheets("Sheet1")


    With ws1
        fr = .Cells(Rows.Count, "A").End(xlUp).Row

        For c = fr To 1 step - 1
            If .Cells(c, "A").Value = "" Then
                .Cells(c, "A").EntireRow.Clear
            End If
        Next c
    End With

End Sub

我上面有一个条件,可以根据某些值重定向页面以登录。我可以在url中看到重定向,因为当我输入

if(){ redirect('Login'); } 更改为http://www.myapp.com

现在,在我的路线中,我有:

http://www.myapp.com/Login

我的登录控制器如下:

$route['default_controller'] = 'welcome';
$route['Login'] = 'login';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

我认为我有

image

但是我为什么要得到

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Login extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->library('session');
        $this->load->model('Login_model');
    }

    public function index(){
        $data['title'] = 'GYM';
        $this->load->view('login',$data);
    }

}

我无法弄清楚配置错误的地方

Object not found! The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again. If you think this is a server error, please contact the webmaster. Error 404 www.myapp.com Apache/2.4.33 (Win32) OpenSSL/1.1.0h PHP/7.2.7 更改配置文件:

Update:

htaccess

$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'].'';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';//'AUTO';
$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~%.:_\-';

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

访问:

RewriteEngine on RewriteCond $1 !^(index\.php|[Javascript / CSS / Image root Folder name(s)]|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L]

有效,但以上所有方法均无效。我不明白为什么

2 个答案:

答案 0 :(得分:1)

尝试在codeigniter应用程序文件夹的根目录级别的.htaccess上添加以下行:

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

答案 1 :(得分:0)

按照以下步骤更改您的值

$route['login'] = 'Login';

$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'].'/';

如果不起作用,请在 htaccess

中替换此代码
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]