HTACCESS redirection with a word replacement in url
Posted
by
Marwen
on Stack Overflow
See other posts from Stack Overflow
or by Marwen
Published on 2011-01-07T20:21:50Z
Indexed on
2011/01/08
4:53 UTC
Read the original article
Hit count: 175
I'm having trouble with this reg expression which i belive is correct, but it is not working.
What im trying to do is redirect bunch of urls containing a specific string like this:
http://www.example.com/**undesired-string**_another-string
to http://www.example.com/**new-string**_another-string
and
http://www.example.com/folder/**undesired-string**/another-string
to http://www.example.com/folder/**new-string**/another-string
So i have this code in the .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule (.+)+(undesired-string)+(.+) $1new-string$2 [R=301,L]
</IfModule>
This should replace ANY undesired-string in any url to new-string, but it is not working, any idea why ?
Thank you
© Stack Overflow or respective owner