apache - PHP架構:yaf的入口檔案index.php是放到根目錄還是public下面?

來源:互聯網
上載者:User
關鍵字 php apache
很多架構都是把index.php放到public下面,但是看到yaf架構有兩個版本(github和文檔),那最好是放到哪裡呢?
我試著把它放到public下面,http://localhost/yaf_test/是無法訪問的,但是http://localhost/yaf_test/public是能重新導向到預設controller下面的,那要怎麼配置才能省略public呢(index.php放在public下面)?

回複內容:

很多架構都是把index.php放到public下面,但是看到yaf架構有兩個版本(github和文檔),那最好是放到哪裡呢?
我試著把它放到public下面,http://localhost/yaf_test/是無法訪問的,但是http://localhost/yaf_test/public是能重新導向到預設controller下面的,那要怎麼配置才能省略public呢(index.php放在public下面)?

apache或nginx配置虛擬路徑指向項目的public檔案夾

apache的httpd.conf中開啟路徑重寫,去掉前面#號

LoadModule rewrite_module modules/mod_rewrite.so

httpd-vhosts.conf中配置一個虛擬路徑

 #監聽連接埠    ##ServerAdmin webmaster@dummy-host2.example.com #管理員郵箱    DocumentRoot "" #項目路徑    ServerName xxx.xxx.com #訪問網址    ##ErrorLog "logs/dummy-host2.example.com-error.log" #錯誤記錄檔    ##CustomLog "logs/dummy-host2.example.com-access.log" common #訪問日誌

hosts中配置

127.0.0.1 xxx.xxx.com

重啟apache,訪問xxx.xxx.com

鳥哥的部落格文檔典型目錄結構也是將index.php放在public中

http://www.laruence.com/manual/tutorial....

public/index.php
最好就放這一個檔案, 這樣才能實現單入口

nginx配置root指向public

server{...root /xxx/xxxx/public;...}

這樣考慮目錄安全性,比如配置目錄 conf 就不用再去單獨限制訪問

放到public下邊吧

我看了很多其他架構的目錄結構,yii,zend framework,laravel是把.htaccess和index.php放到public下面的,phalcon是把.htaccess放到根目錄,index.php放到public下面的

  • 相關文章

    聯繫我們

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