【问题标题】:Rewriting URIs in subdirectory重写子目录中的 URI
【发布时间】:2012-01-04 08:48:41
【问题描述】:

我正在使用 codeigniter 和 .htaccess 重写。目前它正在将所有不存在的文件查询重写为 index.php(CodeIgniter),如下所示:

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

现在,如果文件不存在,我想将以“images”开头的 url 重写为“application/images”。像这样的:

RewriteCond %{REQUEST_URI} ^/images
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ ./application/$1 [L]

嗯,这在根目录中有效,但在子目录中无效。 我不想将子目录名称添加到 htaccess,我希望它是动态的。因此,如果我要复制这个目录并重命名它,我不想将我的 htaccet 更改为这个目录。

RewriteRule 是相对于我正在工作的目录,但 RewriteCond 不是?在此先感谢:)

问题由此解决:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(images|js|css)(.*)$ ./application/$1$2 [L]

【问题讨论】:

    标签: apache .htaccess codeigniter mod-rewrite


    【解决方案1】:
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(images|js|css)(.*)$ ./application/$1$2 [L]
    

    【讨论】:

      猜你喜欢
      • 2022-08-22
      • 1970-01-01
      • 2014-07-14
      • 2012-12-30
      • 1970-01-01
      • 2014-01-27
      • 1970-01-01
      • 2019-05-28
      • 1970-01-01
      相关资源
      最近更新 更多