Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/243.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php .htaccess目录路由_Php_.htaccess_Mod Rewrite_Url Rewriting - Fatal编程技术网

Php .htaccess目录路由

Php .htaccess目录路由,php,.htaccess,mod-rewrite,url-rewriting,Php,.htaccess,Mod Rewrite,Url Rewriting,我一直在用这个键盘敲击我的头,我肯定我错过了一些愚蠢的简单的东西,但是 我使用的是tinyMVC,它通常通过/index.php/hello/foo或其他方式路由请求。我正在尝试设置一个.htaccess文件,这样我就可以不用/index.php/而只需请求/hello/foo。。。tinyMVC文档建议如下(访问/时,应从/web提供文件): 但是,它只返回断开的链接。如果我使用一个查询字符串而不是一个目录(即index.php?qs=$1),它可以很好地为文件提供服务(附带查询字符串),但该

我一直在用这个键盘敲击我的头,我肯定我错过了一些愚蠢的简单的东西,但是

我使用的是tinyMVC,它通常通过/index.php/hello/foo或其他方式路由请求。我正在尝试设置一个.htaccess文件,这样我就可以不用/index.php/而只需请求/hello/foo。。。tinyMVC文档建议如下(访问/时,应从/web提供文件):

但是,它只返回断开的链接。如果我使用一个查询字符串而不是一个目录(即index.php?qs=$1),它可以很好地为文件提供服务(附带查询字符串),但该方法不适用于tinyMVC路由

有什么建议吗

编辑:我的文件结构如下所示:

docroot/
       /web/
           /index.php
       /.htaccess

理想情况下,对mysite.com/hello的请求将透明地路由到mysite.com/web/index.php/hello,MVC控制器将识别到该请求。

我猜目标开头缺少一个“/”

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
编辑

好的,您的评论确实有助于重写规则要求URL而不是目录,因此您不应该编写web部件。

检查错误日志

/var/log/httpd/error_log
当你得到那张破纸的时候

这可能是由于缺少对.htaccess文件的权限

.htaccess文件必须位于文档根文件夹中

DOCROOT/
       /web/
           /index.php
       /.htaccess

希望这能有所帮助。

另外,“/web/”目录是什么?web还是/web,没有交易。/web目录保存所有可公开访问的资源(我将其设置为web目录,但我将其更改回了/以防出现问题。它不是)…htaccess位于doc root中。我将对问题进行编辑,以便更清楚地了解文件结构。
DOCROOT/
       /web/
           /index.php
       /.htaccess