<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ## Yii2 URL地址美化 [TOC]   Web開發中不可避免的要使用到URL。用得最多的就是生成一個指向應用中其他某個頁面的URL。 我們需要一個簡潔的、集中的、統一的方法來完成這一過程。   使用 urlManager組件,我們可以解析用戶的請求并指派相應的`module`, `controller`和`action`來進行處理, 還可以根據預義的路由規則,生成需要的URL返回給用戶使用。 簡而言之,urlManger具有解析請求以便確定指派誰來處理請求和根據路由規則生成URL 2個功能。 ### URL美化 一般情況下,Yii應用生成和接受形如`http://www.domain.com/index.php?r=post/view&id=1`的URL。這個URL分成幾個部分: * 表示主機信息的`http://www.domain.com` * 表示入口腳本的`index.php` * 表示路由的`r=post/view` * 表示普通查詢參數的`id=1` #### 隱藏入口文件 * Nginx位置 ```shell location / { try_files $uri $uri/ /index.php?$args; } ``` * Apache配置文件(放在入門文件同級目錄) ```shell RewriteEngine on # 如果是一個目錄或者文件,就訪問目錄或文件 RewriteCond %{REQUEST_FILENAME} !-d # 如果文件存在,就直接訪問文件,不進行下面的RewriteRule RewriteCond %{REQUEST_FILENAME} !-f RewriteRule . index.php ``` > 另外服務器需要開啟`rewrite`模塊。 #### 配置UrlManager組件 打開`@app/config/main.php`中的`components`下面添加以下代碼,如果想在全局生效可以將配置直接寫入`common`模塊下。 ```php 'components'=>[ ... 'urlManager' => [ 'enablePrettyUrl' => true, 'showScriptName' => false, 'suffix' => '.html', // 偽后綴 'rules'=>[ 'article/<id:\d+>' => 'article/view', // 文章詳情 'articles/<country_id:\d+>' => 'article/index', // 文章列表 ], ], ... ], ``` > 詳細頁面,未優化前訪問路徑為文章 http://www.domain.com/index.php?r=article/detail.html&id=1 ,優化后訪問路徑為:http://www.domain.com.cn/article/1390.html > 文章列表頁面修改前為:http://www.domain.com.cn/article/index.html?country_id=1 ,優化后訪問路徑變為:http://dev.welltrend.com.cn/articles/1.html
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看