简体   繁体   English

Altorouter路由器-> map()无法正常工作

[英]Altorouter router->map() is not working as expected

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

is working just fine when I reloaded index.php page. 重新加载index.php页面时,它工作正常。 var_dump($match) displayed the expected result; var_dump($ match)显示了预期的结果;

However, 然而,

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

is not working when I typed localhost/about. 当我键入localhost / about时无法正常工作。 the browser displayed "Object Not Found" error. 浏览器显示“找不到对象”错误。

I suspected that maybe my root directory was not set correctly, so I also put the follow above $router->map() 我怀疑也许我的根目录设置不正确,所以我也将以下内容放在$ router-> map()上方

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

Unfortunately, setBasePath was not a solution. 不幸的是,setBasePath不是解决方案。

Have you tried any rewrite rule in your .htaccess? 您是否尝试过.htaccess中的任何重写规则?

Try this one 试试这个

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM