Page 1 of 1

How to Replace part of URL via htaccess Rewrite Rule?

Posted: Tue Oct 10, 2017 9:44 am
by arnlweb
Replaceing word mp3 to xuna.

htaccess search and replace.

http://example.com/mp3/the-beatles-come-together

http://example.com/xuna/the-beatles-come-together

Code: Select all

# Arnlweb
# Replace 'mp3' with 'xuna' and 301 redirect 
RewriteRule ^(.*)/mp3/(.*)$ $1/xuna/$2 [R=301,L]
RewriteRule ^mp3/(.*)$ xuna/$1 [R=301,L]
# Arnlweb