Home > Backend Development > PHP Tutorial > apache - PHP框架:yaf的入口文件index.php是放到根目录还是public下面?

apache - PHP框架:yaf的入口文件index.php是放到根目录还是public下面?

WBOY
Release: 2016-06-06 20:13:10
Original
1288 people have browsed it

很多框架都是把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中开启路径重写,去掉前面#号

<code>LoadModule rewrite_module modules/mod_rewrite.so
</code>
Copy after login

httpd-vhosts.conf中配置一个虚拟路径

<code><virtualhost> #监听端口
    ##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 #访问日志
</virtualhost>
</code>
Copy after login

hosts中配置

<code>127.0.0.1 xxx.xxx.com
</code>
Copy after login

重启apache,访问xxx.xxx.com

鸟哥的博客文档典型目录结构也是将index.php放在public中

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

public/index.php
最好就放这一个文件, 这样才能实现单入口

nginx配置root指向public

<code>server{
...
root /xxx/xxxx/public;
...
}</code>
Copy after login

这样考虑目录安全性,比如配置目录 conf 就不用再去单独限制访问

放到public下边吧

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template