yii2.0 Default Access form is: dxr.com/index.php?r=index/list, generally we will be configured to PathInfo form to access: dxr.com/index/list, so more in line with user habits.
The specific configuration method is:
One. Configure yii2.0.
Open the Config directory under web.php, and in $config = [' Components ' =>[add to this]], add:
' Urlmanager ' = [
' Enableprettyurl ' = true,
' Showscriptname ' = False,
' Rules ' = [
],
],
At this point, yii2.0 has been supported in the form of pathinfo access, if not access at this time, continue to look down.
Two. Configure the Web server.
1. If Apache, create a new text file in the directory where the portal file (index.php) is located, then save As. htaccess, open this file with Notepad to join:
Rewriteengine on
Rewritecond%{request_filename}!-f
Rewritecond%{request_filename}!-d
Rewriterule. index.php
Save it.
2. If it is nginx, add it in the Nginx config file:
server {
Listen 80;
server_name www.daixiaorui.com;
Location/{
Root e:/wwwroot/yii2.0;
Index index.html index.php;
if (!-e $request _filename) {
Rewrite ^/(. *)/index.php last;
}
}
Location ~ \.php$ {
Root e:/wwwroot/yii2.0;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
Include Fastcgi_params;
}
}
Three: Restart the Web server.
This completes the configuration.
Article from: http://www.daixiaorui.com/read/218.html This site all articles, in addition to the source is original, reproduced please specify the address of this article, All rights reserved.
yii2.0 configuration is accessed in pathinfo form