Help me why the second redirect works, and the first does not, turned to the hosting technical support and they answered that for the link /component/content/?view=featured there is a conflict with other redirection rules specified in the .htaccess file

 Options +FollowSymLinks RewriteEngine On # не работает Redirect 301 /component/content/?view=featured http://airtech.kz/ # работает Redirect 301 /40-bez-kategorii/285-glavnaya http://airtech.kz/ RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR] RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR] RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR] RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2}) RewriteRule .* index.php [F] RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteCond %{REQUEST_URI} !^/index\.php RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php [L] 

    2 answers 2

    Replace

     Redirect 301 /component/content/?view=featured http://airtech.kz/ 

    on

     RewriteCond %{REQUEST_URI} ^\/component\/content\/$ [NC] RewriteCond %{QUERY_STRING} \bview=featured\b [NC] RewriteRule .* http://airtech.kz/? [R=301,L] 

    PS Technical support reprimand. There is no conflict here.

    • Thank you very much - Mikhail Volkov

    Technical support probably had in mind that the line.

     # не работает Redirect 301 /component/content/?view=featured http://airtech.kz/ # работает Redirect 301 /40-bez-kategorii/285-glavnaya http://airtech.kz/ 

    Conflict in terms of the fact that the work of the first line is overwritten by the execution of the connecting line, as neither the first nor the second line contains the parameter [L] at the end of the lines that interrupts the processing of further lines if the current line has worked.

    • so you want to say that I need to put [L] in the second line too? As in the first line and in the second? in the end it’s right and it’s all like this Redirect 301 /40-bez-kategorii/285-glavnaya http://airtech.kz/ [L] - Mikhail Volkov
    • I speak correctly? - Mikhail Volkov
    • Httpd.apache.org/docs/2.4/rewrite/flags.html#flag_l Here is the documentation about the L flag from the word Last Last. You better use RewriteRule and not Redirect - Dmitriy Gvozd
    • As far as I understand, Redirect is poorly configurable and probably does not support the L flag, so only the second Redirect rule works for you, add the third Redirect rule and only it will work. - Dmitry Gvozd
    • You can test empirically, by committing the second line and checking if the first one works, do not forget to clear the browser's cache when checking, because the browser remembers 301 redirects and then does not look at what the server actually did not give him instructions to redirect. - Dmitriy Gvozd