Tencent / Biny

Biny is a tiny, high-performance PHP framework for web applications
BSD 3-Clause "New" or "Revised" License
1.69k stars 259 forks source link

路由怎么写都不对…… 问题出在哪里了 #26

Closed cwwjsyc closed 6 years ago

cwwjsyc commented 6 years ago

//config/config.php 中写道 'routeRule' => array( 'demo' => 'demo', 'demo.html' => 'demo', '/demo/'=>'demo', ),

//访问 http://*/demo/ or http://*/demo.html 都不对,显示404 求正解!

billge1205 commented 6 years ago

基础路由不需要配置 /demo默认会定位到 controller目录下的 demoAction.php文件 你看下404是框架返回的还是nginx返回的 如果是nginx返回的说明nginx配置的不对 具体配置参考wiki http://www.billge.cc 环境配置

cwwjsyc commented 6 years ago

Object not found!

The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

If you think this is a server error, please contact the webmaster.

Error 404

biny.site Apache/2.4.17 (Win32) OpenSSL/1.0.2d PHP/5.6.21

cwwjsyc commented 6 years ago

<VirtualHost *:80> ServerName biny.site DocumentRoot "C:/XAMMP/htdocs/biny/web" <Directory "C:/XAMMP/htdocs/biny"> AllowOverride All Order Allow,Deny Allow from all

cwwjsyc commented 6 years ago

按照这个配置,我也不知道问题出在哪里了

billge1205 commented 6 years ago

看起来是apache的错误 并没有走到index.php里 apache配置我不是很清楚 nginx最主要是try files的配置 apache 应该也有类似的配置

cwwjsyc commented 6 years ago

既然定位是给入门者使用的框架,那么应该支持Apache+PHP的环境。建议写个.htaccess文件处理下try files的问题

billge1205 commented 6 years ago

嗯 谢谢你的建议 晚点会更新wiki

billge1205 commented 6 years ago
已更新wiki 试试看下面这个配置
DocumentRoot "/data/billge/biny/web/"

<Directory "/data/billge/biny/web/">
    RewriteEngine on
    # 如果请求的是真实存在的文件或目录,直接访问
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    # 如果请求的不是真实文件或目录,分发请求至 index.php
    RewriteRule . index.php

    # ...other settings...  

</Directory>