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

 mobiledu2502853597 发布于 2022-11-18 18:23

很多框架都是把index.php放到public下面,但是看到yaf框架有两个版本(github和文档),那最好是放到哪里呢?
我试着把它放到public下面,http://localhost/yaf_test/是无法访问的,但是http://localhost/yaf_test/public是能重定向到默认controller下面的,那要怎么配置才能省略public呢(index.php放在public下面)?

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

    2022-11-18 18:56 回答
  • 放到public下边吧

    2022-11-18 18:56 回答
  • nginx配置root指向public

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

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

    2022-11-18 18:56 回答
  • public/index.php
    最好就放这一个文件, 这样才能实现单入口

    2022-11-18 18:56 回答
  • apache或nginx配置虚拟路径指向项目的public文件夹

    apache的httpd.conf中开启路径重写,去掉前面#号

    LoadModule rewrite_module modules/mod_rewrite.so
    

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

    <VirtualHost *:80> #监听端口
        ##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>
    

    hosts中配置

    127.0.0.1 xxx.xxx.com
    

    重启apache,访问xxx.xxx.com

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

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

    2022-11-18 18:56 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有