Home > Backend Development > PHP Tutorial > yii2.0 implements the configuration method of pathinfo formal access, yii2.0pathinfo_PHP tutorial

yii2.0 implements the configuration method of pathinfo formal access, yii2.0pathinfo_PHP tutorial

WBOY
Release: 2016-07-12 08:54:19
Original
803 people have browsed it

yii2.0 implements the configuration method of access in the form of pathinfo. The default access form of yii2.0pathinfo

yii2.0 is: dxr.com/index.php?r=index /list, generally we will configure it in the form of 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:
in $config = [ 'components'=>[Add here] ]

'urlManager' => [
 'enablePrettyUrl' => true,
 'showScriptName' => false,
 'rules' => [
 ],
],
Copy after login

At this time, yii2.0 already supports access in the form of pathinfo. If you cannot access it at this time, continue to read below.

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
Copy after login

Save it.

2. If it is nginx, add:
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;
 }
}

Copy after login

Three: Restart the web server.

At this point, the configuration is complete.

Articles you may be interested in:

  • Let Nginx support ThinkPHP URL rewriting and PATHINFO method sharing
  • PHP pathinfo() obtains the path, name and other information of the file Description
  • A brief analysis of pathinfo mode and URL rewriting in ThinkPHP
  • Nginx hidden index.php and Pathinfo mode configuration examples
  • nginx supports codeigniter’s pathinfo mode url rewriting configuration Writing example
  • Example of configuring pathinfo mode in nginx
  • Summary of access mode, path access mode and URL rewriting of pathinfo in ThinkPHP
  • How to enable pathinfo for nginx in lnmp environment
  • Solve the problem that nginx does not support pathinfo in thinkphp

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1120003.htmlTechArticleyii2.0 implements the configuration method of accessing pathinfo. The default access form of yii2.0pathinfo yii2.0 is: dxr.com/index.phpr=index/list, generally we will configure it as pathinfo to access...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template