htaccess的目录路径 [英] .htaccess directory routing

查看:168
本文介绍了htaccess的目录路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在敲打我的头靠在我的键盘与这一个,我敢肯定,这件事情太简单,我很想念,但...

I've been banging my head against my keyboard with this one, and I'm sure it's something stupidly simple that I'm missing, but...

我使用tinyMVC,通常的路线与/index.php/hello/foo或任何要求。我试图建立一个.htaccess文件,这样我可以做到客场与/index.php/,只是请求/你好/烟草工业的tinyMVC文件提出以下建议(文件应该从/网络访问时,曾/):

I'm using tinyMVC, which normally routes requests with /index.php/hello/foo or whatever. I'm trying to set up an .htaccess file so that I can do away with the /index.php/ and just request /hello/foo... the tinyMVC documentation suggests the following (files should be served from /web when accessing /):

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

不过,它只返回断开的链接。如果我使用目录的查询字符串,而不是(即的index.php?QS = $ 1),它服务的文件(附带查询字符串)就好了,但这种方法不能与tinyMVC路由工作。

However, it only returns a broken link. If I use a query string instead of a directory (i.e. index.php?qs=$1), it serves the file (with query string attached) just fine, but that method doesn't work with tinyMVC routing.

有什么建议?

编辑:我的文件结构是这样的:

my file structure looks like this:

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

在理想情况下,请求mysite.com/hello~~V将被透明地路由到mysite.com/web/index.php/hello~~V,这对MVC控制器会承认。

Ideally, requests to mysite.com/hello would be transparently routed to mysite.com/web/index.php/hello, which the MVC controller would recognize.

推荐答案

我的猜测遗漏了'/'的目标开始

My guess a missing '/' at the start of the target

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

修改

确定您的评论并帮助重写规则预计URL没有目录,所以你不应该写的网络部分。

Ok your comment did help the rewrite rule expects URL not directories so you shouldn't write the web part.

这篇关于htaccess的目录路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆