I’d like to 301 redirect all .com/language/X URLs to .com/members/?members_search=X.
Test case:
http://example.com/language/french should 301 redirect to
http://example.com/members/?members_search=french
The rule I have set up:
RedirectMatch 301 "^/language/(.*)" "/members/?members_search=$1"
It works correctly when I use a .htaccess tester. The rule is at the very top of the .htaccess file. Any ideas?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Even though you’ve placed this rule at the top of the .htaccess file, RedirectMatch is a mod_alias directive so still runs after other mod_rewrite (ie. RewriteRule) directives, so you may have a conflict.
Try changing this to a mod_rewrite directive. For example:
RewriteRule ^language/(.*) /members/?members_search=$1 [R=301,L]
NB: No slash prefix on the RewriteRule pattern when used inside .htaccess files.
You will likely need to clear your browser cache before testing. Preferably test with 302 (temporary) redirects to avoid potential caching issues.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0