你应该可以把 2 结合起来。似乎没有任何冲突
https://gist.github.com/24b48c12d82c73e60a37
编辑:
在您的问题中,您还提到您想从 sqeezer 中排除 cms,这个想法是有道理的,但是,您发布的 RewriteRule 根本没有,事实上,如果这没有引发我会感到惊讶错误。
上述规则唯一会做的事情(如果可以的话)就是排除 squeezr 文件被重写到框架,但这无论如何都不会发生,因为之前的RewriteConds 已经否认了这一点(SilverStripe 不会重写现有文件)。
所以你需要做的实际上是在 2 squeezr 规则中添加一个RewriteCond,告诉他们不要使用cms 和framework。
我相信添加以下 2 个条件(就在 squeezr 规则之前)会做到这一点:
RewriteCond %{REQUEST_URI} !cms # exclude the silverstripe cms
RewriteCond %{REQUEST_URI} !framework # exclude the silverstripe framework which is by
(您也可以在此处将其视为要点的差异:https://gist.github.com/Zauberfisch/d681474df67ced83ec1f/revisions)
完整的配置文件:
ErrorDocument 404 /assets/error-404.html
ErrorDocument 500 /assets/error-500.html
<Files *.ss>
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Files>
<Files web.config>
Order deny,allow
Deny from all
</Files>
<Files ~ "\.ya?ml$">
Order allow,deny
Deny from all
</Files>
<IfModule mod_rewrite.c>
Options +FollowSymlinks
# Start the rewrite engine
RewriteEngine On
RewriteBase /
# REDIRECT ANY DIRECT IMAGE REQUEST TO A CACHED VERSION
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{ENV:REDIRECT_BREAKPOINT} !\d+px
RewriteCond %{QUERY_STRING} !^([^&]*&)*squeezr=(0|false|no)
RewriteCond %{HTTP_COOKIE} squeezr.images=(\d+px) [NC]
RewriteCond %{REQUEST_URI} !cms # exclude the silverstripe cms
RewriteCond %{REQUEST_URI} !framework # exclude the silverstripe framework which is by the cms
RewriteRule ^(.+)(\.(?:jpe?g|gif|png))$ squeezr/cache/$1-%1$2 [NC,E=BREAKPOINT:%1,L]
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Please make sure that you set this path ^^^ to the squeezr root directory that is also specified
# for the SQUEEZR_ROOT constant in the common engine configuration (SQUEEZR_ROOT/conf/common.php). If you
# apply the default setup for squeezr (i.e. put everything into a directory named "squeezr" under your
# website's document root), then you shouldn't have to change anything.
#############################################################################################################
# REDIRECT ANY DIRECT CSS REQUEST TO A CACHED VERSION
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{ENV:REDIRECT_BREAKPOINT} !\d+px
RewriteCond %{QUERY_STRING} !^([^&]*&)*squeezr=(0|false|no)
RewriteCond %{HTTP_COOKIE} squeezr.css=(\d+x\d+@\d+(?:\.\d+)?) [NC]
RewriteCond %{REQUEST_URI} !cms # exclude the silverstripe cms
RewriteCond %{REQUEST_URI} !framework # exclude the silverstripe framework which is by the cms
RewriteRule ^(.+)\.css$ squeezr/cache/$1-%1.css [NC,E=BREAKPOINT:%1,L]
# ~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# See above for hints on ^^^ this path.
#############################################################################################################
### SILVERSTRIPE START ###
RewriteRule ^vendor(/|$) - [F,L,NC]
RewriteRule silverstripe-cache(/|$) - [F,L,NC]
RewriteRule composer\.(json|lock) - [F,L,NC]
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\.php$
RewriteRule .* framework/main.php?url=%1 [QSA]
RewriteCond %{REQUEST_URI} ^(.*)/framework/main.php$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . %1/install.php? [R,L]
### SILVERSTRIPE END ###
</IfModule>
#############################################################################################################
# Additional stuff for improving your website's delivery performance
#############################################################################################################
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css text/javascript text/json text/x-json text/x-json-stream application/x-javascript application/json application/x-json application/x-json-stream application/.*xml.* multipart/x-json-stream multipart/x-mixed-replace image/svg+xml
</IfModule>
<IfModule mod_expires.c>
ExpiresActive on
# Images
ExpiresByType image/gif "access plus 35 days"
ExpiresByType image/png "access plus 35 days"
ExpiresByType image/jpg "access plus 35 days"
ExpiresByType image/jpeg "access plus 35 days"
# Text based files
ExpiresByType text/css "access plus 35 days"
ExpiresByType text/xml "access plus 35 days"
ExpiresByType text/javascript "access plus 35 days"
ExpiresByType application/x-shockwave-flash "access plus 35 days"
# Default expiration
ExpiresDefault "access plus 1 days"
</IfModule>