Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

get subdomain from url javascript

url = "http://www.example.com/path/to/somwhere";
urlParts = /^(?:w+://)?([^/]+)([^?]*)??(.*)$/.exec(url);
hostname = urlParts[1]; // www.example.com
path = urlParts[2];
 
PREVIOUS NEXT
Tagged: #subdomain #url #javascript
ADD COMMENT
Topic
Name
3+6 =