in existing production we have URL structure as follows https://mainsite.com/subsite
Now the sub site URL structure changed as follows https://mainsite.com/newsubsite/subsite2
We want to redirect old sub site landing page and all the inner pages to redirect to new url structure I.e., when user browse https://mainsite.com/subsite it should redirect to https://mainsite.com/newsubsite/subsite2
And when user browse https://mainsite.com/subsite/innerpage it should redirect to https://mainsite.com/newsubsite/subsite2/innerpage
The inner page name don't have any name changes. Just need to replace "subsite" with "newsubsite/subsite2"
Edit: one more scenario need to handle. Some times language code e.g.: "en" will come in the URL as like below https://mainsite.com/en/subsite
In this case it need to redirect to https://mainsite.com/en/newsubsite/subsite2
Same for inner pages as well
Any body help me to create a generic rewrite rule to do this job.