The example in this article describes how Yii hides index.php in the URL. Share it with everyone for your reference, the details are as follows:
1. Modify the main.php under config/:
'urlManager'=>array( 'urlFormat'=>'path', 'showScriptName'=>false, 'rules'=>array( '<controller:\w+>/<id:\d+>'=>'<controller>/view', '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>', '<controller:\w+>/<action:\w+>'=>'<controller>/<action>', ), ),
2. Modify the content of the .htaccess file in the root directory of the website as follows:
Options +FollowSymLinks IndexIgnore */* 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
I hope this article will be helpful to everyone’s PHP program design based on the Yii framework.
For more articles related to Yii’s method of hiding index.php in the URL, please pay attention to the PHP Chinese website!