regex - regular expression to negate a string nocache not working -


i trying build regular expression in apache match files extensions .html, .css, .js, .jpg, etc... except url has word "nocache"

i have read other entries in stackoverflow, , i've create following regular expresion

<filesmatch "^(.*(?!nocache)\.(png|bmp|jpg|gif|html|htm|css|js|ttf|svg|woff|txt))$">   expiresactive on   expiresdefault "now plus 1 month" </filesmatch> 

the problem regular expression not working fine. files extensions being cached, file word "nocache" being cached too.

does see problem?

that because put lookahead assertion in wrong place

^(?!.*nocache).*\.(png|bmp|jpg|gif|html|htm|css|js|ttf|svg|woff|txt)$ 

when place before dot, position ahead , sees file extension, not "nocache", true.

in expression placed after anchor , has own .*, start of string, if there "nocache" anywhere in string.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -