On my website, I have following url structure:
example.com/test/ example.com/test/a-page example.com/test/another-page
How can I redirect all of the URLS that contains /test/ right after the domain name to example.com/info/
I understand I can do it using htaccess, but I cannot format the rule syntax.
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
Try the following at the top of your .htaccess file, before the existing WordPress directives:
RewriteRule ^test/ /info/ [R=302,L]
The pattern ^test/ matches all URLs that start /test/.
Note that the URL-path matched by the RewriteRule pattern (first argument) does not start with a slash (when used in .htaccess).
If this is intended to be permanent then change the 302 to 301 – but only after you have tested that it works OK.
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