0

On my lamp installation, I have in the root folder "/" (mydomain.org) a wordpress multisite with W3 total cache activated, I have also a sub_dir called "sub" (mydomain.org/sub) with a PHP script inside.

I have some cache problems on the sub_dir, so I wanna set a RewriteRule to exclude W3 total cache from my sub_dir, the problem is that I have only basic knowledge on this.

htaccess of my root

...

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

htaccess of my sub_dir

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>

and these are my specs:

  • server version: 5.5.40-0ubuntu0.14.04.1 (Ubuntu)
  • Apache/2.4.7(Ubuntu)
  • client version of database: libmysql
  • 5.5.40 extension PHP: mysqli
  • php version: 5.5.9-1ubuntu4.5
dr house
  • 65
  • 1
  • 7

1 Answers1

1

You can define a RewriteCond condition to exclude the sub path in the root htaccess.

It will be something like this (not tested)

...

 # 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

...