HOWTO mod_rewrite的每个请求的index.php除了真正的文件,但排除一个真实目录? [英] howto mod_rewrite every request to index.php except real files but exclude one real directory?

查看:125
本文介绍了HOWTO mod_rewrite的每个请求的index.php除了真正的文件,但排除一个真实目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我解释一下我的情况:

Let me explain my situation:

我使用MVC框架(codeIgniter),所以每一个请求被重写,我的index.php文件,这反过来路由,该到我的类和函数。

I'm using a MVC framework (CodeIgniter), so every request gets rewritten to my index.php file, which in turn routes this to my classes and functions.

Offcours是否有真正的文件的请求,他们不应该被脚本进行处理,而是直接从Web服务器发送到浏览器。

Offcours if there are requests for real files they should not be processed by scripts but directly send from webserver to browser.

Owkay没有问题,下面的重写规则将做到这一点:

Owkay no problem, the following rewrite rules will do just that:

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

我想,对于一个特定的文件夹的要求(我们称之为私人)仍然是PHP处理。这样做的原因。这是我会再验证,如果用户进行身份验证,如果是这样,发送内容到浏览器。

I would like that requests for a certain folder (let call it 'private') still be processed by php. The reason for doing this is that i would then verify if the user is authenticated, and if so, send contents to browser.


  • 在家里的任何Apache大师谁可以帮助?

  • 这是一个可以接受的解决这个问题?

推荐答案

试试这个规则:

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

这将排除那些私人私人/ 即使它们现有的文件夹或启动任何URL路径文件。

This will exclude any URL paths that are private or start with private/ even though they are existing folders or files.

这篇关于HOWTO mod_rewrite的每个请求的index.php除了真正的文件,但排除一个真实目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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