从根目录.htaccess重写规则中排除不允许caching的目录

在我的灯安装,我已经在根文件夹“/”(mydomain.org)W3总caching激活wordpress多站点,我也有一个sub_dir称为“ ”(mydomain.org/sub)与PHP脚本里面。

我有一些sub_dircaching问题,所以我想设置一个RewriteRule从我的sub_dir中排除W3总caching ,问题是,我只有这方面的基本知识。

我的根的htaccess

... # BEGIN W3TC Minify cache <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^[_0-9a-zA-Z-]+/wp-content/cache/minify/[0-9]+/w3tc_rewrite_test$ /wp-content/plugins/w3-total-cache/pub/minify.php?w3tc_rewrite_test=1 [L] </IfModule> # END W3TC Minify cache <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] # add a trailing slash to /wp-admin RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L] RewriteRule . index.php [L] </IfModule> 

我的sub_dir的htaccess

 Options -Indexes +FollowSymLinks RewriteEngine On php_flag opcache.enable Off RewriteBase /sub_dir # exclude any paths that are not codeigniter-app related RewriteCond %{REQUEST_URI} !^/server-status RewriteCond %{REQUEST_URI} !^/server-info RewriteCond %{REQUEST_URI} !^/docs RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d <IfModule mod_php5.c> RewriteRule ^(.*)$ index.php/$1 [L] </IfModule> # the following is for rewritting under FastCGI <IfModule !mod_php5.c> RewriteRule ^(.*)$ index.php?/$1 [L] </IfModule> 

这些是我的规格:

  • 服务器版本:5.5.40-0ubuntu0.14.04.1(Ubuntu)
  • 阿帕奇/ 2.4.7(Ubuntu的)
  • 客户端版本的数据库:libmysql
  • 5.5.40后缀PHP:mysqli
  • PHP版本:5.5.9-1ubuntu4.5

你可以定义一个RewriteCond条件来排除根htaccess中的path。

这将是这样的(没有testing)

 ... # BEGIN W3TC Minify cache <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} !^/sub RewriteRule ^[_0-9a-zA-Z-]+/wp-content/cache/minify/[0-9]+/w3tc_rewrite_test$ /wp-content/plugins/w3-total-cache/pub/minify.php?w3tc_rewrite_test=1 [L] </IfModule> # END W3TC Minify cache ...