yii2.0 configuration is accessed in pathinfo form

Source: Internet
Author: User

yii2.0 Default Access form is: dxr.com/index.php?r=index/list, generally we will be configured to PathInfo form to access: dxr.com/index/list, so more in line with user habits.

The specific configuration method is:

One. Configure yii2.0.

Open the Config directory under web.php, and in $config = [' Components ' =>[add to this]], add:

' Urlmanager ' = [

' Enableprettyurl ' = true,

' Showscriptname ' = False,

' Rules ' = [

],

],

At this point, yii2.0 has been supported in the form of pathinfo access, if not access at this time, continue to look down.

Two. Configure the Web server.

1. If Apache, create a new text file in the directory where the portal file (index.php) is located, then save As. htaccess, open this file with Notepad to join:

Rewriteengine on

Rewritecond%{request_filename}!-f

Rewritecond%{request_filename}!-d

Rewriterule. index.php

Save it.

2. If it is nginx, add it in the Nginx config 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.

This completes the configuration.

Article from: http://www.daixiaorui.com/read/218.html This site all articles, in addition to the source is original, reproduced please specify the address of this article, All rights reserved.

yii2.0 configuration is accessed in pathinfo form

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.