.htaccess - What is L in [QSA, L] in htaccess -


qsa means if there's query string passed original url, appended rewrite (olle?p=1 rewritten index.php?url=olle&p=1.

l means if rule matches, don't process more rewriterules below one.

hi, easy examples explain use of l? can't seem grasp explanation above. highly appreciated. thanks.

the qsa flag means append existing query string after uri has been rewritten. example:

url=http://example.com/foo/bar?q=blah

rule:

rewriterule ^foo/(.*)$ /index.php?b=$1 

result=/index.php?b=bar

notice how q=blah gone. because existing query string dropped in favor of 1 in rule's target, (b=$1). if include qsa flag:

rewriterule ^foo/(.*)$ /index.php?b=$1 [qsa] 

the result becomes=/index.php?b=bar&q=blah


the l flag means stop applying rules follow. given same url, http://example.com/foo/bar?q=blah, , given rules:

rewriterule ^foo -   rewritecond %{request_uri} !^/bar.php rewriterule ^(.*)$ /bar.php?z=$1  

the first rule gets applied , uri gets passed through unchanged (via - target). rewrite engine processes next rule, , uri gets rewritten /bar.php?z=foo/bar. happens when add l end:

rewriterule ^foo - [l]  rewritecond %{request_uri} !^/bar.php rewriterule ^(.*)$ /bar.php?z=$1  

the url http://example.com/foo/bar gets passed through untouched first rule, stops because of l flag. if url http://example.com/something/else first rule doesn't match , second rule gets applied, rewriting uri to: /bar.php?z=something/else

note since rewrite engine loops through rules until uri stops changing, l flag not prevent looping, further rules getting applied in current iteration.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -