The default access form of yii2.0 is: dxr.com/index.php?r=index/list. Generally, we will configure it as pathinfo to access: dxr.com/index/list, which is more in line with user habits.
The specific configuration method is:
1. Configure yii2.0.
Open web.php in the config directory, and add:
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
],
],
At this time, yii2.0 already supports access in the form of pathinfo. If Unable to access, continue reading.
2. Configure the web server.
1. If it is apache, create a new text file in the directory where the entry file (index.php) is located, then save it as .htaccess, open this file with Notepad and add:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
Save it.
2. If it is nginx, add in the nginx configuration 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 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.
At this point, the configuration is complete.
The article comes from: http://www.daixiaorui.com/read/218.html All articles on this site are original unless the source is indicated. Please indicate the address of this article when reprinting. All rights reserved.
The above introduces the access of yii20 configuration in the form of pathinfo, including the content of pathinfo. I hope it will be helpful to friends who are interested in PHP tutorials.