0
$router->setBasePath('/ecommerce/public');
$router->map( 'GET', '/', '', 'about_us' );
$match = $router->match();

当我重新加载 index.php 页面时工作得很好。var_dump($match) 显示了预期的结果;

然而,

$router->map( 'GET', '/about', '', 'about_us' )  

当我输入 localhost/about 时不起作用。浏览器显示“找不到对象”错误。

我怀疑可能是我的根目录设置不正确,所以我也在$router->map()上面放了following

$router->setBasePath('/ecommerce/public');

不幸的是,setBasePath 不是一个解决方案。

4

1 回答 1

0

您是否在 .htaccess 中尝试过任何重写规则?

试试这个

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
于 2018-09-27T09:20:19.213 回答