


yii2.0 implements the configuration method of pathinfo formal access, yii2.0pathinfo_PHP tutorial
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' => [ ], ],
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
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; } }
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

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.

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())

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

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~.
