Reputation: 4310
Simple question here.
I need to replace all instances of a string in the URL with another string.
IE. I need to replace every instance of "test" in the URL, with .htaccess code.
For example "www.example.com/test/A/test/B/test" will become "www.example.com/REP/A/REP/B/REP".
I can produce a script that replaces "test" with "REP", when "test" is not at the end or the beginning of the script. But I cannot come up with a final script to replace "test" everywhere.
My code:
RewriteRule ^test\/(.*) REP/$1 [L,R=301]
Thanks!
Upvotes: 1
Views: 409
Reputation: 4310
I found an answer, that is all knowing and beatiful.
RewriteRule ^(.*)test(.*)$ $1FIN$2 [R=301,L]
Upvotes: 1