Friday, December 27, 2019

Htaccess | what does $1 in .htaccess file mean | Check if file exists in subdirectory

$1 is the first captured group from your regular expression; that is, the contents between ( and ). If you had a second set of parentheses in your regex, $2 would contain the contents of those parens and so on. Here is an example:
RewriteRule (js|css|img)/(.*?).(js|css|jpg|jpeg|png|ttf)$ public/$1/$2.$3 [NC,L,QSA]
Will served files as below:

js/app.js will be served from public/js/app.js

css/main.css will be served from public/css/main.css

1 comment:

  1. In .htaccess, $1 captures the value of the first matched fluentbit group in a RewriteRule, and to check if a file exists in a subdirectory, use -f or -d condition.






    ReplyDelete