开发者

.htaccess directory routing

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...

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]

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.

Any suggestions?

EDIT: my file structure looks like this:

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

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]

EDIT

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


Check the error log

/var/log/httpd/error_log

while you get the broken page.

It may be due to lack of permission to .htaccess file.

The .htaccess file has to be in the document root folder.

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

Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜