繁体   English   中英

苗条的PHP框架的htaccess配置

[英]htaccess config for slim php framework

我使用Slim php框架在index.php页面内构建一些动作:这就是我所说的动作的方式:

的index.php /动作1

$app->get('/action1',function () use ($app){
            echo "this is action 1";
});

的index.php /动作2

$app->get('/action2',function () use ($app){
            echo "this is action 2";
});

现在我希望我的网址变得漂亮,例如在输入index / action1时

,它将重定向到index.php / action1
请为我提供创建htaccess的解决方案
感谢和最好的问候

创建.htaccess文件

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]

为您的路线添加前缀的用户组

$app->group('/index', function () use ($app) {
    /**
     * Route GET /index/action1
     */
    $app->get('/action1',function () use ($app){
        echo "this is action 1";
    });
});

暂无
暂无

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

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