Table of Contents
yii2.0配置以pathinfo的形式访问,yii2.0pathinfo
Home php教程 php手册 yii2.0配置以pathinfo的形式访问,yii2.0pathinfo

yii2.0配置以pathinfo的形式访问,yii2.0pathinfo

Jun 13, 2016 am 08:42 AM
path pathinfo by of access Configuration

yii2.0配置以pathinfo的形式访问,yii2.0pathinfo

yii2.0默认的访问形式为:dxr.com/index.php?r=index/list,一般我们都会配置成pathinfo的形式来访问:dxr.com/index/list,这样更符合用户习惯。

具体的配置方法为:

 

一.配置yii2.0。

打开config目录下的web.php,在$config = [ 'components'=>[ 加到这里 ] ]中加入:

'urlManager' => [

  'enablePrettyUrl' => true,

  'showScriptName' => false,

  'rules' => [

  ],

],

此时,yii2.0已经支持以pathinfo的形式访问了,如果此时访问不了,继续往下看。

 

二.配置web服务器。

1.如果是apache,在入口文件(index.php)所在的目录下新建一个文本文件,接着另存为.htaccess,用记事本打开此文件加入:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php

保存即可。

 

2.如果是nginx,在nginx配置文件中加入:

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;

}

}

 

三:重启web服务器。

 

至此,配置完毕。

 

文章出自:http://www.daixiaorui.com/read/218.html 本站所有文章,除注明出处外皆为原创,转载请注明本文地址,版权所有。

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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

The working principle and configuration method of GDM in Linux system The working principle and configuration method of GDM in Linux system Mar 01, 2024 pm 06:36 PM

The working principle and configuration method of GDM in Linux system

The perfect combination of PyCharm and PyTorch: detailed installation and configuration steps The perfect combination of PyCharm and PyTorch: detailed installation and configuration steps Feb 21, 2024 pm 12:00 PM

The perfect combination of PyCharm and PyTorch: detailed installation and configuration steps

Understand Linux Bashrc: functions, configuration and usage Understand Linux Bashrc: functions, configuration and usage Mar 20, 2024 pm 03:30 PM

Understand Linux Bashrc: functions, configuration and usage

MyBatis Generator configuration parameter interpretation and best practices MyBatis Generator configuration parameter interpretation and best practices Feb 23, 2024 am 09:51 AM

MyBatis Generator configuration parameter interpretation and best practices

How to configure workgroup in win11 system How to configure workgroup in win11 system Feb 22, 2024 pm 09:50 PM

How to configure workgroup in win11 system

Flask installation and configuration tutorial: a tool to easily build Python web applications Flask installation and configuration tutorial: a tool to easily build Python web applications Feb 20, 2024 pm 11:12 PM

Flask installation and configuration tutorial: a tool to easily build Python web applications

Smooth build: How to correctly configure the Maven image address Smooth build: How to correctly configure the Maven image address Feb 20, 2024 pm 08:48 PM

Smooth build: How to correctly configure the Maven image address

Where can I check the configuration of my win11 computer? How to find the configuration information of win11 computer Where can I check the configuration of my win11 computer? How to find the configuration information of win11 computer Mar 06, 2024 am 10:10 AM

Where can I check the configuration of my win11 computer? How to find the configuration information of win11 computer

See all articles