homepage Welcome to WebmasterWorld Guest from 54.234.74.85
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
<FilesMatch ".(js|css)$"> vs <filesMatch "\.(js|css)$">
ewwatson




msg:4518017
 1:44 pm on Nov 11, 2012 (gmt 0)

Specifically "\."

Should I include the slash or no? Whats it do?

this is part of a deflate htacces rule

<FilesMatch ".(js|css|html|htm|php|xml)$">
SetOutputFilter DEFLATE
</FilesMatch>

or there is this version

<filesMatch "(?i)^.*\.(ico|flv|jpg|jpeg|png|gif|js|css)$">

So..

"(?i)^.*\." vs "\." vs "."

 

phranque




msg:4518021
 2:26 pm on Nov 11, 2012 (gmt 0)

<FilesMatch ".(js|css)$"> vs <filesMatch "\.(js|css)$">

neither.

as far as i know the apache directives are case sensitive.
also the directive matches a "Perl Compatible Regular Expression", so you need the backslash to escape the dot.

<FilesMatch> Directive:
http://httpd.apache.org/docs/2.2/mod/core.html#filesmatch

(?i)

i would not make the file extensions case insensitive unless you are actually serving uppercase or mixed case file names.

ewwatson




msg:4518023
 2:30 pm on Nov 11, 2012 (gmt 0)

OK thanks. So what should this look like exactly?

<FilesMatch ".(js|css|html|htm|php|xml)$">
SetOutputFilter DEFLATE
</FilesMatch>

phranque




msg:4518025
 2:39 pm on Nov 11, 2012 (gmt 0)

the directive matches a "Perl Compatible Regular Expression", so you need the backslash to escape the dot

ewwatson




msg:4518035
 2:53 pm on Nov 11, 2012 (gmt 0)

OK like this?

# Compress Files
<FilesMatch "\.(js|css|html|htm|php|xml)$">
SetOutputFilter DEFLATE
</FilesMatch>

ewwatson




msg:4518146
 12:19 am on Nov 12, 2012 (gmt 0)


OK like this?

# Compress Files
<FilesMatch "\.(js|css|html|htm|php|xml)$">
SetOutputFilter DEFLATE
</FilesMatch>

g1smd




msg:4518155
 12:57 am on Nov 12, 2012 (gmt 0)

\. matches a literal period.

. matches ANY character.

ewwatson




msg:4518162
 1:37 am on Nov 12, 2012 (gmt 0)

Ok thanks! So prob better to match a period. I have a question you may know the answer to. I'm desperately trying to enable coaching for my website. I put this in my htaccess...

ExpiresActive On
ExpiresDefault "access plus 10 years"
ExpiresByType text/html "access plus 1 day"

But it's not caching. Reading for hours I see mod_expires needs to be on the server in order for my code to work. I have Hostgator shared server. I have talked to multiple tecks at Hostgator and they all are unable to give me an answer if they have mod_expires or mod_headers on the server. I am at a loss. Have any of you experienced any of this and possibly a fix?

lucy24




msg:4518189
 3:12 am on Nov 12, 2012 (gmt 0)

Hm, thought this thread sounded familiar. Some hosts won't give out details about what mods are available or what version of Apache they're using. Mine won't-- but to make up for it they show you a nifty trick for revealing exactly which mods you have available. (The one that involves #printenv and an htaccess file. You've probably seen it.)

Are you testing it on new pages that you haven't previously visited? Emptying your browser cache or preferably testing in an entirely different browser? A default of "expires never" -- which is basically what "access plus 10 years" means -- will probably be overridden by some lower number set by your browser.

If the Expires header is intended to apply to everything, you don't need the <Files> or <FilesMatch> envelope at all. But that's the least of your problems.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved