What does $1 [QSA,L] mean in my .htaccess file?

前端 未结 3 523
北荒
北荒 2020-11-28 19:48

I need to change my .htaccess and there are two lines which I don\'t understand.

RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.+)$ index.p         


        
3条回答
  •  误落风尘
    2020-11-28 20:06

    If the following conditions are true, then rewrite the URL:
    If the requested filename is not a directory,

    RewriteCond %{REQUEST_FILENAME} !-d
    

    and if the requested filename is not a regular file that exists,

    RewriteCond %{REQUEST_FILENAME} !-f
    

    and if the requested filename is not a symbolic link,

    RewriteCond %{REQUEST_FILENAME} !-l
    

    then rewrite the URL in the following way:
    Take the whole request filename and provide it as the value of a "url" query parameter to index.php. Append any query string from the original URL as further query parameters (QSA), and stop processing this .htaccess file (L).

    RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
    

    Apache docs #flag_qsa

    Another Example:

    RewriteRule "/pages/(.+)" "/page.php?page=$1" [QSA]
    

    With the [QSA] flag, a request for

    /pages/123?one=two

    will be mapped to

    /page.php?page=123&one=two

提交回复
热议问题