Purpose: I just want to get rid of the index.php?r= in the browser address bar.
Add the following code to the ' components ' =>[ in/config/web.php:
1' Urlmanager ' = [2' Enableprettyurl ' =true,3' Showscriptname ' =false,//Hide index.php4 //' enablestrictparsing ' = False,5' Suffix ' = '. html ',//suffix, if this is set, then the browser address bar must be brought with an. html suffix, or 404 error will be reported6' Rules ' = [7 //' <controller:\w+>/<action:\w+> ' = ' <controller>/<action> ',8],9],
If you have changed the suffix this look, be sure to add the. html to the path of the browser's address bar.
Changed the above, I found that ? r= This piece can be used / instead of access, but want to hide index.php or not.
We also need to add the. htaccess file under the index.php sibling directory:
Open Notepad and enter the following code:
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< C9/>rewriterule. index.php
It is then saved in the same directory as the portal file index.php, which is the/web directory, and the file name is filled in. htaccess, Files of type select All Files (*. *) , and then save.
The final Test is OK!
Yii2 simple address beautify and hide index.php