This article mainly introduces the configuration method for implementing pathinfo access in yii2.0. For more information, see the default access method in yii2.0: dxr.com/index.php? R = index/list, which is usually configured as pathinfo to access: dxr.com/index/list.
The specific configuration method is as follows:
1. configure yii2.0.
Open web. php in the config directory and add it to $ config = ['components' => [add here:
'urlManager' => [ 'enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => [ ],],
In this case, yii2.0 supports access in the form of pathinfo. if the access fails at this time, continue to look down.
2. configure the web server.
1. for apache, create a text file in the directory where the entry File (index. php) is located, save it as. htaccess, open the file in notepad, and add:
RewriteEngine onRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . index.php
Save it.
2. for nginx, add the following to the nginx configuration file:
server { listen 80; server_name localhost; 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; }}
3. restart the web server.
Now, the configuration is complete.