


Yii2.0 implements the configuration method of pathinfo formal access
This article mainly introduces the relevant information on the configuration method of yii2.0 to implement pathinfo form access. Friends in need can refer to it
The default access form of 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:
'urlManager' => [ 'enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => [ ], ],
## in $config = [ 'components'=>[Add here] ]
2. Configure the web server.
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php
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; } }
to the nginx configuration file. Three: Restart the web server.
At this point, the configuration is complete. The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website! Related recommendations:How to export excel tables in the YII2 framework
The above is the detailed content of Yii2.0 implements the configuration method of pathinfo formal access. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











How to remove jquery from yii2: 1. Edit the AppAsset.php file and comment out the "yii\web\YiiAsset" value in the variable $depends; 2. Edit the main.php file and add the configuration "'yii" under the field "components" \web\JqueryAsset' => ['js' => [],'sourcePath' => null,]," to remove the jquery script.

This article will introduce you to the yii2 framework, share a few CTF exercises, and use them to learn the yii2 framework. I hope it will be helpful to everyone.

1. You need to download the windows version of the master branch of yii2-redis with composer 2. Unzip and copy it to vendor/yiisoft 3. Add 'yiisoft/yii2-redis'=>array('name'=>'yiisoft to extensions.php under yiisoft /yii2-redis','version'=>'2.0.

The reason is that I haven’t used Apache for a long time, and I gradually feel unfamiliar with Apache, because my friend has a zendframework framework that was moved from Apache to nginx and requires pathinfo mode support. So I started searching online for articles related to nginx+pathinfo. I thought it would be easy to configure it at first. After searching, I found that there are a lot of articles introducing nginx to enable pathinfo mode, and it seems that it is not difficult. But after several hours, it is still not configured properly. And the contents of a large number of articles are very similar, and they are basically reprinted. Starting to get a little anxious! Because one day has passed and the preparation has not been completed. There is no solution to continue groping, so continue searching. For the convenience of verification, I use a.c

In Yii2, there are two main ways to display error prompts. One is to use Yii::$app->errorHandler->exception() to automatically catch and display errors when an exception occurs. The other is to use $this->addError(), which displays an error when model validation fails and can be accessed in the view through $model->getErrors(). In the view, you can use if ($errors = $model->getErrors())

nginx configuration pathinfo hides index.php Put this code in the nginx configuration file server{listen80;default_typetext/plain;root/var/www/html;indexindex.phpindex.htmindex.html;#hide index.phplocation/{if(!- e$request_filename){#First-level directory#rewrite^/(.*)$/index.php/$1last;#Second-level directory rewrite^/myapp/(.*)$/myapp/

This article will explain in detail the information about the file path returned by PHP. The editor thinks it is quite practical, so I share it with you as a reference. I hope you can gain something after reading this article. PHP obtains file path information In PHP, you can obtain detailed information of a specified file path through the pathinfo() function. This function returns an array containing information about various parts of the file path. Syntax pathinfo(string$path,int$options=PATHINFO_DIRNAME|PATHINFO_BASENAME|PATHINFO_EXTENSION|PATHINFO_FILENAME) parameter $pat

To transfer apache to nginx, $_server['path_info'] is used on the code side. Pathinfo is not enabled by default for nginx. So we have to manually enable 1, url rewrite location/{//Method 1if(!-e$request_filename){rewrite^/(.*)$/index.php/$1last;break;}}location/{/ /Method 2try_files$uri$uri//index.php$uri;}2, pathinfo sets location~.
