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

I need to change my .htaccess , and there are two lines that I do not understand.

 RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.+)$ index.php?url=$1 [QSA,L] 

When should I use these lines?

+74
.htaccess
Sep 23 '12 at 10:05
source share
3 answers

Not a place for a complete tutorial, but here it is short:

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

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

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

L means that if the rule matches, do not process any more RewriteRules below this.

For more information about this, follow the links above. Overwrite support may be a little hard to understand, but a few examples can be found from stackoverflow.

+173
Sep 23 '12 at 10:30
source share

If the following conditions are true, rewrite the URL:
If the requested file name is not a directory,

 RewriteCond %{REQUEST_FILENAME} !-d 

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

 RewriteCond %{REQUEST_FILENAME} !-f 

and if the requested file name is not a symbolic link,

 RewriteCond %{REQUEST_FILENAME} !-l 

then rewrite the url like this:
Take all the name of the request file and specify it as the value of the url request parameter for index.php. Add the query string from the source URL as optional query parameters (QSA) and stop processing this .htaccess (L) file.

 RewriteRule ^(.+)$ index.php?url=$1 [QSA,L] 
+2
Jul 21 '17 at 0:03
source share

This will lead to the capture of requests for files such as version , release and README.md , etc., which should be processed either as endpoints, if they are defined (as in the case of / release) or as "not found".

0
Sep 13 '17 at 4:50
source share



All Articles