Reputation: 367
I have this rule in Angularjs app. It work perfectly. But I want to understand one rule which I don't know what it does RewriteRule ^.*$ - [NC,L] #???
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -!f
RewriteRule ^.*$ - [NC,L] #NC none-case-sensitive, L stop when match
RewriteRule ^(.*) index.html [NC,L]
Please help me on this rule RewriteRule ^.*$ - [NC,L]
I know about the [NC,L]
flags but I don't get ^.*$ -
especially the empty dash at the end of rule.
Upvotes: 3
Views: 81
Reputation: 62733
The syntax of the RewriteRule
is:
RewriteRule Pattern Substitution [flags]
Your rule is:
RewriteRule ^.*$ - [NC,L]
^.*$
is a perl compatible regular expression where
^
is the start of string.
is any character except newline*
means 0 or more times$
is the end of string.The substiution is -
which means: "no substitution should be performed (the existing path is passed through untouched). This is used when a flag needs to be applied without changing the path."
The flags are NC
and L
, which means:
NC
: Makes the pattern comparison case-insensitive.L
: Stop the rewriting process immediately and don't apply any more rules. Especially note caveats for per-directory and .htaccess context (see also the END flag).So this rule matches anything, makes no substitution, and stops the rewriting process immediately.
Upvotes: 1