簡體   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