KMX
KMX

Reputation: 2691

mod_rewrite rule to replace a sub-string from a URL

I need to do this:

I have an old URL:

http://www.mysite.com/dev-site/some-content-part-here

That I want to make into:

http://www.mysite.com/live/some-content-part-here

Edit

I found somebody voted down on my question. I dont know what thought drove him/her to that but actually the question really was not that silly! May be the downer did not understand why I asked this... it could be anything in his mind. But I want all readers, if you dont like question - please always try to communicate through comments and then if the question poster does not agree your changes, then down vote. Thanks.

*And guys, thanks for editing.

Upvotes: 9

Views: 9109

Answers (1)

Tim Čas
Tim Čas

Reputation: 10867

Untested:

RewriteEngine On

RewriteRule ^/dev-site/(.*)$ http://www.mysite.com/live/$1 [R=301,L]

Note that it might work if you only use /live/$1 on the right hand side, but I'd do this to be sure.

I know you know this (since you've mentioned mod_rewrite), but for those that don't, you generally put this into the .htaccess file in the directory - either dev-site or root should work.

Upvotes: 3

Related Questions