Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace subdomain name with other subdomain Using JavaScript?

I'm trying to replace the subdomain name from "news.domain.com/path/.." to "mobile.domain.com/path/..", using JavaScript

Any idea how to achieve this?

like image 445
Bala Avatar asked Apr 18 '13 14:04

Bala


People also ask

Can you change subdomain name?

When you're ready to rename your subdomain, you can follow these steps to change. Only the account owner can rename the subdomain. In Admin Center, click Account in the sidebar, then select Appearance > Branding. In the Subdomain section, click Change your subdomain.

Can you have a subdomain of a subdomain?

All subdomains are on the same level. You won't have a subdomain within a subdomain like you would a subfolder within a subfolder.

Can you have 2 subdomains?

You create subdomains to help organize and navigate to different sections of your main website. Within your main domain, you can have as many subdomains as necessary to get to all of the different pages of your website.


1 Answers

I'm assuming that you want to change a string in the generic format xxxx.domain.com/... into mobile.domain.com/.... This regexp should do it in JavaScript:

var oldPath = "news.domain.com/path/";
var newPath = oldPath.replace(/^[^.]*/, 'mobile')
like image 61
FixMaker Avatar answered Oct 11 '22 18:10

FixMaker