欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

yii2.0實(shí)現(xiàn)pathinfo的形式訪問(wèn)的配置方法

 更新時(shí)間:2016年04月06日 15:43:43   投稿:hebedich  
這篇文章主要介紹了yii2.0實(shí)現(xiàn)pathinfo的形式訪問(wèn)的配置方法的相關(guān)資料,需要的朋友可以參考下

yii2.0默認(rèn)的訪問(wèn)形式為:dxr.com/index.php?r=index/list,一般我們都會(huì)配置成pathinfo的形式來(lái)訪問(wèn):dxr.com/index/list,這樣更符合用戶習(xí)慣。

具體的配置方法為:

一.配置yii2.0。

打開(kāi)config目錄下的web.php,在$config = [ 'components'=>[ 加到這里 ] ]中加入:

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

此時(shí),yii2.0已經(jīng)支持以pathinfo的形式訪問(wèn)了,如果此時(shí)訪問(wèn)不了,繼續(xù)往下看。

二.配置web服務(wù)器。

1.如果是apache,在入口文件(index.php)所在的目錄下新建一個(gè)文本文件,接著另存為.htaccess,用記事本打開(kāi)此文件加入:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php

保存即可。

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

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;
 }
}

三:重啟web服務(wù)器。

至此,配置完畢。

相關(guān)文章

最新評(píng)論