Forum Moderators: phranque
and
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{QUERY_STRING} ^language=sp$
RewriteRule .* http://www.example.com/ [L,R=301]
?
The only difference is the ? symbol at the end of the rewriterule.
Thanks in advance
What should be the difference of behaviour among this
RewriteCond %{QUERY_STRING} ^language=sp$
RewriteRule .* http://www.example.com/? [L,R=301]
this
RewriteCond %{QUERY_STRING} ^language=sp$
RewriteRule ^$ http://www.example.com/? [L,R=301]
and this
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{QUERY_STRING} ^language=sp$
RewriteRule .* http://www.example.com/? [L,R=301]
?
Is it supposed that checking RewriteCond %{REQUEST_URI} ^/$
returns always true because all the URI's start with "/"?
Thanks
The second rule matches only a request for "/" and so anything not matching that will immediately abort this rule. That will make for quicker processing. The rule will then only run for the single '/?language=sp' request. This will be quicker to process than the first rule.
The third rule will does exactly the same job as the second rule, but will take longer to process because first it matches .* everything, and then has to test the first RewriteCond. Moving the pattern from the first RewriteCond to be the left side of the Rule speeds things up.
Patterns on the left side of a RewriteRule are localised to the current directory level, so ^$ matches a URL request for "/" and ^foo$ matches a URL request for "/foo".