【问题标题】:codeigniter File not found issue with function in URIcodeigniter File not found URI中的函数问题
【发布时间】:2016-11-23 13:12:10
【问题描述】:

我会尽量简单地解释我的问题。

我的索引 URI 也可以正常工作,并显示我的“测试”消息。

https :// domain.com /

其他 URI 不起作用并显示“找不到文件”消息。

https :// domain.com / about

然而,这个 URI 就像我想要的那样工作:

https :// domain.com / index.php / about

我真的不明白为什么,有人可以帮助我吗?感谢您的帮助 ! :)

我的路线

$route['default_controller'] = 'pages/view';
$route['(:any)'] = 'pages/view/$1';

我的 .htaccess

RewriteEngine on

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}  [R=301,L]

RewriteRule ^pages/view(/)?(.*)$ /$2 [R=301,L]
RewriteRule ^pages(/)?(.*)$ /$2 [R=301,L]

RewriteCond $1 !^((user_guide|img|css|js|scripts|fonts)\/.*|index\.php|assets/|robots\.txt|.*\.css)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

我的控制器文件名

Pages.php

我的控制器类

<?php
class Pages extends CI_Controller {

    public function view($page = 'home')
    {
        echo'test';
        exit;
    }
}
?>

我的配置 uri 协议(我已经尝试过使用 QUERY_STRING 和 PATH_INFO)

$config['uri_protocol'] = 'REQUEST_URI';

很高兴得到您的帮助!

【问题讨论】:

    标签: codeigniter


    【解决方案1】:

    尝试在 .htaccess 中使用以下内容并检查。

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} -s [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]
    

    【讨论】:

    • 欢迎 Galex!很高兴对您有所帮助。
    猜你喜欢
    • 1970-01-01
    • 2019-06-10
    • 2011-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多