- First enable the rewrite module in the server configuration (httpd.conf):
#Open the rewrite module and remove the # in front of it LoadModule rewrite_module modules/mod_rewrite.so #Directory allows overrides enabled <Directory "${SRVROOT}/htdocs"> # # Possible values for the Options directive are "None", "All", # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you. # # The Options directive is both complicated and important. Please see # http://httpd.apache.org/docs/2.4/mod/core.html#options # for more information. # Options Indexes FollowSymLinks # # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride All # # Controls who can get stuff from this server. # Require all granted </Directory>
- Add the server configuration file .htaccess to the directory
RewriteEngine on ############################### # @email [email protected] # @author test ############################### # rewrite rules #If it is a directory or file, access the directory or file RewriteCond %{REQUEST_FILENAME} !-d #If the file exists, access the file directly without performing the following RewriteRule RewriteCond %{REQUEST_FILENAME} !-f RewriteRule . index.php
- Add the urlManager configuration item to the framework configuration item \frontend\config\main.php
'urlManager' => [ 'enablePrettyUrl' => true, 'showScriptName' => false, //'suffix' => '.html',//URL后缀 ],
- By the way, don't forget to restart the server after modifying the server configuration, if there is any error, look at the server log, this is very important
YII framework routing configuration
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=325216089&siteId=291194637
Recommended
Ranking