3

私が示すものを除いて、すべての JavaScript ファイルと CSS ファイルに縮小アクションを適用する必要があります。

すべてのファイル (css および js) に適用されるこの条件とルールがあります。

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*\.)(js|css)$ minify.php?q=$1$2 [L,NC]

次の条件を追加する必要があります。

jquery.js、prototype.js などを除くすべてに適用されます。

4

3 に答える 3

9

これを試して

RewriteCond %{REQUEST_FILENAME} !^.*jquery.js$
RewriteCond %{REQUEST_FILENAME} !^.*prototype.js$
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*\.)(js|css)$ minify.php?q=$1$2 [L,NC]

これの鍵は、「!」を使用した正規表現の反転です。(感嘆符) ファイル名が jquery.js ではなく、prototype.js ではなく、ハード ドライブ上にあることを示します。

于 2009-02-19T19:56:43.030 に答える
1

を使用RewriteCondして、 を適用する条件を指定できますRewriteRule。したがって、これらの行を の先頭に追加します.htaccess

RewriteCond %{REQUEST_FILENAME} !jquery.js
RewriteCond %{REQUEST_FILENAME} !prototype.js
于 2009-02-19T19:57:36.757 に答える
0

ありがとうございます!私は、ほぼ1か月間、私の問題に対するこの答えを探してきました。私の問題は、一部のファイルをhttpsに、残りをhttpに書き換える方法でしたが、上記を変更して機能させることができました。これが私のコードの一部です。(サイトの実際の .htaccess には、さらに多くのファイルがあります。)

#################################################################
# To only change certain files from http to https, the rest from 
# https to http. Absolute links are set up throughout the site, 
# but if a visitor for some reason edits the URL in the address
# bar, the URL will change back to the proper format.

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^alvingolf\.com$ [NC]
RewriteCond %{HTTPS} on
RewriteCond %{SERVER_PORT} ^443$ 
RewriteCond %{REQUEST_FILENAME} !^.*contact-us.html$
RewriteCond %{REQUEST_FILENAME} !^.*register-for-tournaments.html$
RewriteCond %{REQUEST_FILENAME} !^.*form.htm$
于 2009-06-01T15:50:07.543 に答える