ThinkPHP在SAE下關於url重寫的有關問題

來源:互聯網
上載者:User
ThinkPHP在SAE下關於url重寫的問題
thinkphp。
根目錄下有config.yaml(因為SAE不支援.htaccess)
內容為:

name: thinktest
version: 1
handle:
- rewrite: if(!is_dir() && !is_file() && path~"^(.*)$") goto "/index.php/$1"
- rewrite: if(path~"^/test\.html$") goto "/test.php"

關鍵看第二個重寫。
在根目錄下有test.html和test.php
訪問test.html的時候可以訪問到test.php

問題是
有入口檔案index.php
Action裡有檔案IndexAction.class.php
其中index作業碼如下:

  echo "";

即頁面跳轉。
同時在Tpl/default/Index/下有test.html和test.php
此時跳轉後不會訪問到test.php

不過如果是跳轉到根目錄下的test.html的話就沒問題。

是不是跟config.yaml的作用範圍有關?還是有其他原因?

求高手解答!

------解決方案--------------------
thinkphp 的偽靜態是通過 PATH_INFO 實現的
唯一可能需要使用 url 重寫的是: 隱藏 index.php 檔案名稱

thinkphp 是單一入口的,所以不會出現 http://serverName/test.php 這樣的 url

這一點無論是從
.htaccess 的
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
還是config.yaml的
- rewrite: if(!is_dir() && !is_file() && path~"^(.*)$") goto "index.php/$1"
都可以看出:他將網域名稱外的所有內容都轉換成了index.php的參數
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.