smartweb 发表于 2020-7-11 08:01:37

CI4的路由到底改成什么样了?

.htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{ENV:REDIRECT_APP_PATH} !^$
RewriteRule ^(.*)$ -

RewriteCond %{ENV:APP_PATH} ^$
RewriteRule ^(.*)$ -

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php
#RewriteRule ^(.*)$ index.php/$1

RewriteCond %{REQUEST_METHOD} ^TRACE
RewriteRule .* -



-------
App.php
public $indexPage = '';

------
Routes.php
$routes->get('/', 'Home::index');
$routes->get('xx', 'Home::xx');


-----
Home.php

public function index()
        {
                return view('welcome_message');
        }
public function xx()
        {
                echo "xx";
        }


----
但为什么
http://127.0.0.1:2405/可以正常浏览,而
http://127.0.0.1:2405/xx   却显示No input file specified.

Routes.php改成
$routes->add('xx', 'Home\xx');
也一样出同样的错误。

smartweb 发表于 2020-7-11 08:05:33

http://127.0.0.1:2405/index.php/home/xx   却反而可以访问

louaolin 发表于 2020-7-11 19:02:40

伪静态问题,检查一下环境。。。。。。。

smartweb 发表于 2020-7-12 09:53:42

感觉根目录已经变到public里了。外国资料是将public的index.php和.htaccess复制到根目录下面进行,我试了还不行。最后找了ci3的.htaccess放到public里面,http://127.0.0.1:2405/home/xx可以访问了。

smartweb 发表于 2020-7-12 09:56:19

不用定义routers.php,\app\Controllers写了Products.php,http://127.0.0.1:2405/products 也可以访问了
页: [1]
查看完整版本: CI4的路由到底改成什么样了?