简体   繁体   English

苗条的PHP框架的htaccess配置

[英]htaccess config for slim php framework

I use Slim php framework to build some action inside index.php page: so this is the way I call my action: 我使用Slim php框架在index.php页面内构建一些动作:这就是我所说的动作的方式:

index.php/action1 的index.php /动作1

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

index.php/action2 的index.php /动作2

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

Now I want my url become pretty , such as when type in index/action1 现在我希望我的网址变得漂亮,例如在输入index / action1时

, it will redirect to index.php/action1 ,它将重定向到index.php / action1
Please provide me the solution in creating htaccess to do that 请为我提供创建htaccess的解决方案
Thank and best reagard 感谢和最好的问候

Create .htaccess file 创建.htaccess文件

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

user group to prefix your route 为您的路线添加前缀的用户组

$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