很多架構都是把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下面的