dou47732 2016-10-27 09:23
浏览 17
已采纳

Phalcon PHP Project没有映射(显示目录视图的服务器)

I'm in the early stages of migrating a website into a Phalcon PHP framework. However I've stumbled on the first problem.

I've set the Phalcon project up all fine as specified by various tutorials. I've checked to see my server has Phalcon installed which it does and I've uploaded the project into the /www directory. However now when I browse to the URL instead of getting the nice rendered webpage, I literally just get a directory view of my server (Screenshot 1). Even when I dig into the directory of my Phalcon project it still only goes into the directory view (Screenshot 2). It is only when I browse to /phalcon-project/public that it finally recognises and renders the index from the Controllers and Views via the bootstrap index.php in the public directory (Screenshot 3).

Any ideas on why it's not mapping? Note, as you can see in my top level (/www) I have 2 directories; let's call them /phalcon-project and /other-website as I have another site running from there (no PHP frameworks on that site, just a plain boring old static site) my URL www.phalcon-project.com maps to the /www directory and my url www.other-site.com maps to /www/other-site... I don't see that this should be causing an issue, but could it possibly be that, or something else?

Screenshot 1:

Screenshot 1

Screenshot 2:

Screenshot 2

Screenshot 3:

Screenshot 3

  • 写回答

1条回答 默认 最新

  • dongshan1396 2016-10-27 12:29
    关注

    It sounds like you have not set up the virtual host correctly. You can either modify it to make the root /www/public or alternatively utilise a .htaccess file as detailed on the Phalcon website.

    https://docs.phalconphp.com/uk/latest/reference/apache.html

    So in your case you would have the following in a .htaccess file in your document root. (/www)

    <IfModule mod_rewrite.c>
      RewriteEngine on
      RewriteRule  ^$ public/    [L]
      RewriteRule  ((?s).*) public/$1 [L]
    </IfModule>
    

    Then the following .htaccess file inside the /www/public directory.

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^((?s).*)$ index.php?_url=/$1 [QSA,L]
    </IfModule>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵