Hide GET parameter from URL

后端 未结 5 1447
故里飘歌
故里飘歌 2020-12-18 08:44

How to hide URL GET parameters (http://domain.com/MyFirstYii/page?view=about). I\'ve searched lot of posts. They all are saying about rewrite and URL manager, but i couldn\'

5条回答
  •  借酒劲吻你
    2020-12-18 09:32

    uncomment these line from main.php

    'urlManager'=>array(
                            'urlFormat'=>'path',
                            'showScriptName'=>false,
                            'rules'=>array(
                                    'MyFirstYii/post/'=>'MyFirstYii/post', 
                                    '/'=>'/view',
                                    '//'=>'/',
                                    '/'=>'/',
                            ),
                    ),
    

    And put .htaccess file in root directory of project and write following code

    RewriteEngine on
    
    # if a directory or a file exists, use it directly
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    # otherwise forward it to index.php
    RewriteRule . index.php
    

提交回复
热议问题