The default Web site access path looks like this:
Http://127.0.0.1:8080/zuizen/index.php?r=admin/UserInfo/admin
This path is unfriendly to search engines and needs to be changed to the following form:
Http://127.0.0.1:8080/zuizen/admin/UserInfo/admin.html
The following steps achieve the above requirements:
1 Modify Apache configuration so that it supports rewriting:
Open the Apache configuration file httpd.conf: Open the Apache mod_rewrite module:
Remove the "#" symbol before the LoadModule rewrite_module modules/mod_rewrite.so
Ensure "allowoverride all" in <directory "d:/var/www/html" ></Directory>
Restart Apache.
2 Modify Yii Web site configuration:
Locate the Urlmanager under components in the/protected/config/main.php in the project and modify it to:
' Urlmanager ' =>array (
' Urlformat ' => ' path ',
' Rules ' =>array (),
' Showscriptname ' =>false,
' Urlsuffix ' => '. html ',
),
Urlformat set Path: The default value is get, that is, the requested resource (/path/to/entryscript.php?name1=value1&name2=value2 ...) is represented in the URL by a got parameter R. Path is represented by a path:
(/path/to/entryscript.php/name1/value1/name2/value2 ...) )。
Showscriptname set to false: the Portal file "/index.php" does not appear in the URL, at which point you need to set the forwarding rules for the Web server to forward requests that are not explicitly resource locations to the portal file.
Rules set the parameter mapping mode of the action, expressed in regular expressions, see Curlmanager
3 Add rewrite permissions for the Web site:
Add the file ". htaccess" at the same level as the site root index.php file, which reads 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
4 can now be accessed using the desired path format.