Mod_rewrite to replace substring from url

I need to do this:

I have an old URL:

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

What I want to do:

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

Edit

<i> I found that someone voted for my question. I do not know what thought prompted him to do this, but in fact the question really was not so stupid! Maybe someone did not understand why I asked about it ... it could be anything in his mind. But I want all readers, if you do not like the question - please always try to communicate through comments, and then if the questionnaire does not agree with your changes, then skip the vote. Thanks.

* And guys, thanks for editing.

+6
source share
1 answer

Unverified:

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

Note that this might work if you only use /live/$1 on the right side, but I would do this to make sure.

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

+2
source

Source: https://habr.com/ru/post/909314/


All Articles