Home > Backend Development > PHP Tutorial > The yii2.0 configuration is accessed in the form of pathinfo, yii2.0pathinfo_PHP tutorial

The yii2.0 configuration is accessed in the form of pathinfo, yii2.0pathinfo_PHP tutorial

WBOY
Release: 2016-07-12 08:55:30
Original
846 people have browsed it

yii2.0 configuration is accessed 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' => [

],

],

The yii2.0 configuration is accessed in the form of pathinfo, yii2.0pathinfo_PHP tutorial

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

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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1116659.htmlTechArticleyii2.0 configuration is accessed 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: dx...
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