主頁 > 知識庫 > Yii框架的路由配置方法分析

Yii框架的路由配置方法分析

熱門標簽:電子圍欄 服務器配置 科大訊飛語音識別系統(tǒng) Mysql連接數(shù)設置 阿里云 Linux服務器 團購網(wǎng)站 銀行業(yè)務

本文實例講述了Yii框架的路由配置方法。分享給大家供大家參考,具體如下:

取消index.php

這兩種方法都是在自動添加index.php

方法一:使用.htaccess

添加.htaccess文件  與index.php同級

RewriteEngine on
# if a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward the request to index.php
RewriteRule . index.php

方法二:vhost

VirtualHost *:80>
    ServerName public.oa.com
    DocumentRoot "D:\phpStudy\PHPTutorial\WWW\OA\frontend\web"
    Directory "D:\phpStudy\PHPTutorial\WWW\OA\frontend\web">
      # use mod_rewrite for pretty URL support
      RewriteEngine on
      # If a directory or a file exists, use the request directly
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      # Otherwise forward the request to index.php
      RewriteRule . index.php
      # use index.php as index file
      DirectoryIndex index.php
      # ...other settings...
      # Apache 2.4
      Require all granted
      ## Apache 2.2
      # Order allow,deny
      # Allow from all
    /Directory>
/VirtualHost>

Yii配置

    'urlManager' => [
      //美化路由
      'enablePrettyUrl' => true,
      //不啟用嚴格解析
      'enableStrictParsing' => false,
      //index.php是否顯示
      'showScriptName' => false,
      //偽靜態(tài)化 seo
      'suffix' => '.html',
      //美化規(guī)則
      'rules' => [
        //第一條:文章詳細頁
        'controller:\w+>/id:\d+>'=>'controller>/detail',
        //第二條:文章列表頁
        'post'=>'post/index',
      ],
    ],

更多關于Yii相關內容感興趣的讀者可查看本站專題:《Yii框架入門及常用技巧總結》、《php優(yōu)秀開發(fā)框架總結》、《smarty模板入門基礎教程》、《php面向對象程序設計入門教程》、《php字符串(string)用法總結》、《php+mysql數(shù)據(jù)庫操作入門教程》及《php常見數(shù)據(jù)庫操作技巧匯總》

希望本文所述對大家基于Yii框架的PHP程序設計有所幫助。

您可能感興趣的文章:
  • Yii入門教程之目錄結構、入口文件及路由設置
  • 詳解PHP的Yii框架的運行機制及其路由功能
  • Yii2.0 Basic代碼中路由鏈接被轉義的處理方法
  • Yii2框架控制器、路由、Url生成操作示例
  • YII分模塊加載路由的實現(xiàn)方法
  • yii2的restful api路由實例詳解
  • Yii學習總結之安裝配置
  • Yii配置與使用memcached緩存的方法
  • Yii2配置Nginx偽靜態(tài)的方法
  • Yii框架中sphinx索引配置方法解析

標簽:大理 棗莊 衢州 萍鄉(xiāng) 蚌埠 廣元 衡水 江蘇

巨人網(wǎng)絡通訊聲明:本文標題《Yii框架的路由配置方法分析》,本文關鍵詞  ;如發(fā)現(xiàn)本文內容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權與本站無關。
  • 相關文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266