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

前端 未结 3 521
北荒
北荒 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:08

    Not the place to give a complete tutorial, but here it is in short;

    RewriteCond basically means "execute the next RewriteRule only if this is true". The !-l path is the condition that the request is not for a link (! means not, -l means link)

    The RewriteRule basically means that if the request is done that matches ^(.+)$ (matches any URL except the server root), it will be rewritten as index.php?url=$1 which means a request for ollewill be rewritten as index.php?url=olle).

    QSA means that if there's a query string passed with the original URL, it will be appended to the rewrite (olle?p=1 will be rewritten as index.php?url=olle&p=1.

    L means if the rule matches, don't process any more RewriteRules below this one.

    For more complete info on this, follow the links above. The rewrite support can be a bit hard to grasp, but there are quite a few examples on stackoverflow to learn from.

提交回复
热议问题