htaccess codeigniter mod-rewrite,rewritecond以忽略主应用程序目录中的子目录 [英] htaccess codeigniter mod-rewrite, rewritecond to ignore subdirectory within main app directory

查看:92
本文介绍了htaccess codeigniter mod-rewrite,rewritecond以忽略主应用程序目录中的子目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了Codeigniter,可以运行,一切都很好.除了我现在想为我的用户提供一种上传图像的方法.我唯一可以想到的将文件夹放置在应用程序目录中(在我的情况下,将其适当地重命名为"app").反正.由于它是MVC,因此我需要在各处运行重写条件.我相信这是其中的一种情况.

I have an install of codeigniter up, running and all is good. Except I want to now offer my users a means of uploading images. The only place I could think to put the folder was in the applications directory (aptly renamed to "app" in my case). Anyway. Since its an MVC I need to run rewrite conditions all over the place. And I believe this to be one of the scenarios.

我需要的是在app文件夹中具有适用于此子文件夹的条件

What I need is to have a condition that works for this subfolder within the app folder

我原来的重写条件是

RewriteCond $1 !^(index\.php|static|robots\.txt)

这对于那些情况非常有效,但不适用于这种情况,因此我需要一种适用于上述情况但支持应用程序/上传的新条件(甚至可能)?

which works great for those but not for this one case so I need a new condition that works with the above but supports app/upload (is this even possible)?

推荐答案

如果您将资产保留在application/之外(如罗伯特所述),生活会容易得多.

Life's a lot easier if you keep your assets outside of application/ (as Robert mentioned).

您也可以从很多优秀的资产管理火花中选择-我为我创作了一个名为 sk-asset 的CI项目,它提供了许多视图帮助程序.结构化:

There are a ton of good asset management Sparks you can pick from to assist with this too - I authored one for my CI projects called sk-asset which provides a lot of view helpers & is structured:

  • /CIAppRoot
    • 资产/
      • css/
      • 下载/
      • img/
      • js/
      • 少/
      • swf/
      • 上传/
      • xml/
      • /CIAppRoot
        • assets/
          • css/
          • download/
          • img/
          • js/
          • less/
          • swf/
          • upload/
          • xml/

          ... htaccess设置可以简单地绕过现有文件/目录/等的CI路由:

          ... htaccess settings can simply bypass CI routing for existing files/dirs/etc:

          <IfModule mod_rewrite.c>
            Options +FollowSymlinks
            RewriteEngine On
          
            # block hidden directories
            RewriteRule "(^|/)\." - [F]
          
            RewriteCond $1 !^(index\.php|assets|robots\.txt|favicon\.ico)
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
          RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
          </IfModule>
          

          这篇关于htaccess codeigniter mod-rewrite,rewritecond以忽略主应用程序目录中的子目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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