I am very new in coding and redirection in .htaccess
.
I would need a redirection for a lot of URLs with the slug /brand/
.
For example:
https://example.com/brand/AAA to /shop/?filter_marke=AAA
https://example.com/brand/BBB to /shop/?filter_marke=BBB
https://example.com/brand/CCC to /shop/?filter_marke=CCC
and so on.
You could perform the "redirect" like the following using mod_rewrite:
The order of rules can be important. This would need to go near the top of the
.htaccess
file, before any existing rewrites. If this is a WordPress site, then it would need to go before the# BEGIN WordPress
comment marker.The
$1
backreference in the substitution string (2nd argument) contains the value of the word after/brand/
in the URL-path.UPDATE:
In that case you can simply append a trailing slash to the end of the pattern, ie.
^brand/(\w+)/$
. Or make the trailing slash optional so it matches both. ie.^brand/(\w+)/?$
.