Configuration method for implementing pathinfo access in yii2.0, yii2.0pathinfo

Source: Internet
Author: User

Configuration method for implementing pathinfo access in yii2.0, yii2.0pathinfo

The default access format of yii2.0 is dxr.com/index.php? R = index/list, which is usually configured as pathinfo to access: dxr.com/index/list.

The specific configuration method is as follows:

1. Configure yii2.0.

Open web. php In the config directory and add it to $ config = ['components' => [add here:

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

In this case, yii2.0 supports access in the form of pathinfo. If the access fails at this time, continue to look down.

2. Configure the web server.

1. For apache, create a text file in the directory where the entry file (index. php) is located, save it as. htaccess, open the file in notepad, and add:

RewriteEngine onRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . index.php

Save it.

2. For nginx, add the following 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; }}

3. Restart the web server.

Now, the configuration is complete.

Articles you may be interested in:
  • Let Nginx support ThinkPHP URL rewriting and PATHINFO method sharing
  • PHP pathinfo () obtains the file path, name, and other information descriptions.
  • Analysis on pathinfo mode and URL rewriting in ThinkPHP
  • An example of how to hide the index. php and Pathinfo modes in Nginx
  • Nginx supports codeigniter pathinfo mode url rewriting configuration example
  • Example of configuring pathinfo mode in nginx
  • Summary of pathinfo access mode, path access mode, and URL rewriting in ThinkPHP
  • Enable pathinfo for nginx in lnmp Environment
  • Solve the problem that nginx does not support pathinfo in thinkphp.

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.