ThinkPHP的URL重寫問題_PHP教程

來源:互聯網
上載者:User
我想要的結果無非是去掉URL路徑中的index.php

首先是配置.htaccess

RewriteEngine onRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]

因為我部署在apache上面,需要httpd.conf設定檔中找到LoadModule rewrite_module modules/mod_rewrite.so去掉前面的#,找到AllowOverride None改為AllowOverride All。

現在訪問localhost/product有效,但是__APP__或者__URL__或者U擷取出來的路徑包含有index.php,也就是為localhost/index.php,原來還有一步,需要在conf/config.php裡面修改或者添加'URL_MODEL'=>2,

而因為我嘗試部署的是基於ThinkPHP的conist企業版2.0,在config.php裡竟然有這麼一個配置'URL_MODEL' =>C('TOKEN.false_static'),,而TOKEN.false_static的值在初始化的時候被設定為了1,所以。。。模式一直還是1,PATHINFO模式。

在新浪SAE部署,不支援.htaccess,只支援其自有的設定檔config.yaml,所以要在config.yaml添加下面這段重寫格式代碼:

handle:- rewrite: if(!is_dir() && !is_file() && path~"^(.*)$") goto "index.php/$1"

http://www.bkjia.com/PHPjc/825531.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/825531.htmlTechArticle我想要的結果無非是去掉URL路徑中的index.php 首先是配置.htaccess IfModule mod_rewrite.cRewriteEngine onRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FI...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.